Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on VBA.
I am using Excel 2000
I want to print the following information in the footer: 1. File path, File name and worksheet name 2. Print Date and time in the print out 3. Last Saved by user "xyz" 4. Last saved time 5. Page numer I am currently using the following VBA code in my file: VBAProject(mario.xls) Microsoft Excel Objects ThisWorkBook ---------------------------------------------------------- Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "&8" & _ LCase(ActiveWorkbook.FullName) & "; Worksheet:" & " &A " & _ vbCrLf & "Printed on:" & Format(Now(), "dd-mmm- yyyy") .RightFooter = "&8" & "Page &P of &N" End With End Sub ---------------------------------------------------------- Please help me with 1. How to go to the next line in footer after printing the file name & path. "vbcrlf" actually introduces an empty line and then prints on the second line., which I dont want 2. What will be the VBA code for Printing the date in the format like 19 Sept 2003, 13:30 3. What will be the VBA code to print the "Last Saved By" and "Last Saved time" Please help. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on VBA.
"mario" wrote in message ... Please help me with 1. How to go to the next line in footer after printing the file name & path. "vbcrlf" actually introduces an empty line and then prints on the second line., which I dont want Try vbLf instead of vbCrLf 2. What will be the VBA code for Printing the date in the format like 19 Sept 2003, 13:30 Can't get 4 char month I am afraid, but can do 3 Format(Now(),"dd mmm dddd, hh:mm") 3. What will be the VBA code to print the "Last Saved By" and "Last Saved time" ActiveWorkbook.BuiltinDocumentProperties("Last Author") and ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), giving a final result of Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "&8" & _ LCase(ActiveWorkbook.FullName) & "; Worksheet:" & " &A " & _ vbLf & "Printed on:" & Format(Now(), "dd-mmm-yyyy ") & _ vbLf & "Saved: by " & ActiveWorkbook.BuiltinDocumentProperties("Last Author") & _ " on " & Format(ActiveWorkbook.BuiltinDocumentProperties("L ast Save Time"), "dd mmm dddd, hh:mm") .RightFooter = "&8" & "Page &P of &N" End With End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on VBA.
Hi Mario,
Bob's code for the date formatting should be: Format(Now(),"dd mmm yyyy, hh:mm") I'm sure he accidentally put "dddd" instead of "yyyy". You could also use: Format(Now(),"dd mmm yyyy, h:mm AM/PM") If you want to show the time differently. Regards, James S -----Original Message----- "mario" wrote in message ... Please help me with 1. How to go to the next line in footer after printing the file name & path. "vbcrlf" actually introduces an empty line and then prints on the second line., which I dont want Try vbLf instead of vbCrLf 2. What will be the VBA code for Printing the date in the format like 19 Sept 2003, 13:30 Can't get 4 char month I am afraid, but can do 3 Format(Now(),"dd mmm dddd, hh:mm") 3. What will be the VBA code to print the "Last Saved By" and "Last Saved time" ActiveWorkbook.BuiltinDocumentProperties("Last Author") and ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), giving a final result of Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "&8" & _ LCase(ActiveWorkbook.FullName) & "; Worksheet:" & " &A " & _ vbLf & "Printed on:" & Format(Now(), "dd-mmm- yyyy ") & _ vbLf & "Saved: by " & ActiveWorkbook.BuiltinDocumentProperties("Last Author") & _ " on " & Format (ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "dd mmm dddd, hh:mm") .RightFooter = "&8" & "Page &P of &N" End With End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on VBA.
Hey Man,
Thanks a million. Every thing is perfect now. Have a niece weekend. Regards Mario -----Original Message----- "mario" wrote in message ... Please help me with 1. How to go to the next line in footer after printing the file name & path. "vbcrlf" actually introduces an empty line and then prints on the second line., which I dont want Try vbLf instead of vbCrLf 2. What will be the VBA code for Printing the date in the format like 19 Sept 2003, 13:30 Can't get 4 char month I am afraid, but can do 3 Format(Now(),"dd mmm dddd, hh:mm") 3. What will be the VBA code to print the "Last Saved By" and "Last Saved time" ActiveWorkbook.BuiltinDocumentProperties("Last Author") and ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), giving a final result of Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "&8" & _ LCase(ActiveWorkbook.FullName) & "; Worksheet:" & " &A " & _ vbLf & "Printed on:" & Format(Now(), "dd-mmm- yyyy ") & _ vbLf & "Saved: by " & ActiveWorkbook.BuiltinDocumentProperties("Last Author") & _ " on " & Format (ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "dd mmm dddd, hh:mm") .RightFooter = "&8" & "Page &P of &N" End With End Sub . |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on VBA.
Thanks for your help. Can u suggest how I can save these changes to default or template file, so that every file I create have those information on the footer Thanks -----Original Message----- Hi Mario, Bob's code for the date formatting should be: Format(Now(),"dd mmm yyyy, hh:mm") I'm sure he accidentally put "dddd" instead of "yyyy". You could also use: Format(Now(),"dd mmm yyyy, h:mm AM/PM") If you want to show the time differently. Regards, James S -----Original Message----- "mario" wrote in message ... Please help me with 1. How to go to the next line in footer after printing the file name & path. "vbcrlf" actually introduces an empty line and then prints on the second line., which I dont want Try vbLf instead of vbCrLf 2. What will be the VBA code for Printing the date in the format like 19 Sept 2003, 13:30 Can't get 4 char month I am afraid, but can do 3 Format(Now(),"dd mmm dddd, hh:mm") 3. What will be the VBA code to print the "Last Saved By" and "Last Saved time" ActiveWorkbook.BuiltinDocumentProperties("Last Author") and ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), giving a final result of Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "&8" & _ LCase(ActiveWorkbook.FullName) & "; Worksheet:" & " &A " & _ vbLf & "Printed on:" & Format(Now(), "dd-mmm- yyyy ") & _ vbLf & "Saved: by " & ActiveWorkbook.BuiltinDocumentProperties("Last Author") & _ " on " & Format (ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "dd mmm dddd, hh:mm") .RightFooter = "&8" & "Page &P of &N" End With End Sub . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on VBA.
Mario,
Notwithstanding my previous typo. Put the workbook event code into a new, pristine workbook, and save the file as a template file called Book.xlt in the XLStart directory. Be aware though, every time you New a workbook, it will throw up the macros dialog. -- HTH Bob Phillips "mario" wrote in message ... Thanks for your help. Can u suggest how I can save these changes to default or template file, so that every file I create have those information on the footer Thanks -----Original Message----- Hi Mario, Bob's code for the date formatting should be: Format(Now(),"dd mmm yyyy, hh:mm") I'm sure he accidentally put "dddd" instead of "yyyy". You could also use: Format(Now(),"dd mmm yyyy, h:mm AM/PM") If you want to show the time differently. Regards, James S -----Original Message----- "mario" wrote in message ... Please help me with 1. How to go to the next line in footer after printing the file name & path. "vbcrlf" actually introduces an empty line and then prints on the second line., which I dont want Try vbLf instead of vbCrLf 2. What will be the VBA code for Printing the date in the format like 19 Sept 2003, 13:30 Can't get 4 char month I am afraid, but can do 3 Format(Now(),"dd mmm dddd, hh:mm") 3. What will be the VBA code to print the "Last Saved By" and "Last Saved time" ActiveWorkbook.BuiltinDocumentProperties("Last Author") and ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), giving a final result of Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "&8" & _ LCase(ActiveWorkbook.FullName) & "; Worksheet:" & " &A " & _ vbLf & "Printed on:" & Format(Now(), "dd-mmm- yyyy ") & _ vbLf & "Saved: by " & ActiveWorkbook.BuiltinDocumentProperties("Last Author") & _ " on " & Format (ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "dd mmm dddd, hh:mm") .RightFooter = "&8" & "Page &P of &N" End With End Sub . |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA Help
Hi Bob,
One final help. What will be the VBA code for Created by and Created on which i should be adding to your code. Please help Thanks -----Original Message----- Mario, Notwithstanding my previous typo. Put the workbook event code into a new, pristine workbook, and save the file as a template file called Book.xlt in the XLStart directory. Be aware though, every time you New a workbook, it will throw up the macros dialog. -- HTH Bob Phillips "mario" wrote in message ... Thanks for your help. Can u suggest how I can save these changes to default or template file, so that every file I create have those information on the footer Thanks -----Original Message----- Hi Mario, Bob's code for the date formatting should be: Format(Now(),"dd mmm yyyy, hh:mm") I'm sure he accidentally put "dddd" instead of "yyyy". You could also use: Format(Now(),"dd mmm yyyy, h:mm AM/PM") If you want to show the time differently. Regards, James S -----Original Message----- "mario" wrote in message ... Please help me with 1. How to go to the next line in footer after printing the file name & path. "vbcrlf" actually introduces an empty line and then prints on the second line., which I dont want Try vbLf instead of vbCrLf 2. What will be the VBA code for Printing the date in the format like 19 Sept 2003, 13:30 Can't get 4 char month I am afraid, but can do 3 Format(Now(),"dd mmm dddd, hh:mm") 3. What will be the VBA code to print the "Last Saved By" and "Last Saved time" ActiveWorkbook.BuiltinDocumentProperties("Last Author") and ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), giving a final result of Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftFooter = "&8" & _ LCase(ActiveWorkbook.FullName) & "; Worksheet:" & " &A " & _ vbLf & "Printed on:" & Format(Now(), "dd-mmm- yyyy ") & _ vbLf & "Saved: by " & ActiveWorkbook.BuiltinDocumentProperties("Last Author") & _ " on " & Format (ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "dd mmm dddd, hh:mm") .RightFooter = "&8" & "Page &P of &N" End With End Sub . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|