![]() |
Concatinating strings in a footer
I am having a problem with the delopment of some code to construct a footer.
By creating a macro I got the following: ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftFooter = "&""Times New Roman,Regular""&8Path String&F" End With I am trying to construct a footer string on the fly, concatenating the font formatting ("&""Times New Roman,Regular""&8), the Path String and the auto file name (&F") I tried several things including assigning the entire string to a variable causing Excel to ignore the control (&) characters as well as assigning the string components to several variables causing Excel's VBA engine to cough up a hairball. Any ideas? -- Sierk |
Concatinating strings in a footer
Sub formatt()
Dim s As String dq = Chr(34) pound = "&" s = pound & dq & "Times" & dq & "Hello World" ActiveSheet.PageSetup.CenterHeader = s End Sub As you can see, the only tricky point is getting the double quote (dq) in the proper place in the string. -- Gary''s Student - gsnu200827 "Sierk" wrote: I am having a problem with the delopment of some code to construct a footer. By creating a macro I got the following: ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftFooter = "&""Times New Roman,Regular""&8Path String&F" End With I am trying to construct a footer string on the fly, concatenating the font formatting ("&""Times New Roman,Regular""&8), the Path String and the auto file name (&F") I tried several things including assigning the entire string to a variable causing Excel to ignore the control (&) characters as well as assigning the string components to several variables causing Excel's VBA engine to cough up a hairball. Any ideas? -- Sierk |
Concatinating strings in a footer
Thanks. It makes sense now. The confusion came from me not understanding
the function of the control characters: So .LeftFooter = pound & dq & "Times" & dq & "Hello World" would actually translate into: .LeftFooter = "&""Times""Hello World" This puts "Hello World" (without quotes) in your footer using the Times font -- Sierk "Gary''s Student" wrote: Sub formatt() Dim s As String dq = Chr(34) pound = "&" s = pound & dq & "Times" & dq & "Hello World" ActiveSheet.PageSetup.CenterHeader = s End Sub As you can see, the only tricky point is getting the double quote (dq) in the proper place in the string. -- Gary''s Student - gsnu200827 "Sierk" wrote: I am having a problem with the delopment of some code to construct a footer. By creating a macro I got the following: ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftFooter = "&""Times New Roman,Regular""&8Path String&F" End With I am trying to construct a footer string on the fly, concatenating the font formatting ("&""Times New Roman,Regular""&8), the Path String and the auto file name (&F") I tried several things including assigning the entire string to a variable causing Excel to ignore the control (&) characters as well as assigning the string components to several variables causing Excel's VBA engine to cough up a hairball. Any ideas? -- Sierk |
Concatinating strings in a footer
The confusion is not your problem alone.
I can never remember whether to type a single double-quote, two double-quotes, or three double-quotes. That why I usually use the variable dq -- Gary''s Student - gsnu200827 "Sierk" wrote: Thanks. It makes sense now. The confusion came from me not understanding the function of the control characters: So .LeftFooter = pound & dq & "Times" & dq & "Hello World" would actually translate into: .LeftFooter = "&""Times""Hello World" This puts "Hello World" (without quotes) in your footer using the Times font -- Sierk "Gary''s Student" wrote: Sub formatt() Dim s As String dq = Chr(34) pound = "&" s = pound & dq & "Times" & dq & "Hello World" ActiveSheet.PageSetup.CenterHeader = s End Sub As you can see, the only tricky point is getting the double quote (dq) in the proper place in the string. -- Gary''s Student - gsnu200827 "Sierk" wrote: I am having a problem with the delopment of some code to construct a footer. By creating a macro I got the following: ActiveSheet.PageSetup.PrintArea = "" With ActiveSheet.PageSetup .LeftFooter = "&""Times New Roman,Regular""&8Path String&F" End With I am trying to construct a footer string on the fly, concatenating the font formatting ("&""Times New Roman,Regular""&8), the Path String and the auto file name (&F") I tried several things including assigning the entire string to a variable causing Excel to ignore the control (&) characters as well as assigning the string components to several variables causing Excel's VBA engine to cough up a hairball. Any ideas? -- Sierk |
All times are GMT +1. The time now is 12:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com