behest
asked on
Formatting results of .RightFooter = ActiveWorkbook.Keywords after results pulled
Well, I'm feeling mighty stumped! I finally got the file keywords to appear in a footer, but no of the font formatting combinations I add to the line are working. Lots of "Complie errors" = massive frustration! Below is the essence of the simple code...please help me figure out what I'm doing wrong. As you can see, I've commented out the formatting but wanted you to see it.
With ActiveSheet.PageSetup
.LeftFooter = "&""Times New Roman,Regular""&12 &P"
' .RightFooter = "&""Times New Roman,Regular""&8"
.RightFooter = ActiveWorkbook.Keywords
With ActiveSheet.PageSetup
.LeftFooter = "&""Times New Roman,Regular""&12 &P"
' .RightFooter = "&""Times New Roman,Regular""&8"
.RightFooter = ActiveWorkbook.Keywords
Hi,
Can you try the following....
- Ardhendu
Can you try the following....
- Ardhendu
Sub one()
Dim strng
strng = ActiveWorkbook.Keywords
With ActiveSheet.PageSetup
.LeftFooter = "&""Times New Roman,Regular""&12&P"
.RightFooter = "&""Times New Roman,Regular""&8" & strng
End With
End Sub
Kevin,
I didn't see ur comment before i posted. Sorry about that.
Behest,
The points should be awarded to Kevin, as his solution is better than mine.
Thanks,
Ardhendu
I didn't see ur comment before i posted. Sorry about that.
Behest,
The points should be awarded to Kevin, as his solution is better than mine.
Thanks,
Ardhendu
ASKER
Kevin, if only I lived in your 'hood. I'm using Office 2007 (fyi). Although the formatting works, the ActiveWorkbook.Keywords chunk doesn't pull the keywords property. Instead, I see a blank right footer.
I've tried
.RightFooter = ActiveWorkbook.Keywords"&" "Times New Roman,Regular""&8"
and many other variations. I even hoped (in vain) that I could pull the keywords field in one line, then go back and format the results. My clumsy method for writing that bit didn't work.
Is there perhaps a way to pull the field, then go back and have whatever results are pulled formatted appropriately?
I've tried
.RightFooter = ActiveWorkbook.Keywords"&"
and many other variations. I even hoped (in vain) that I could pull the keywords field in one line, then go back and format the results. My clumsy method for writing that bit didn't work.
Is there perhaps a way to pull the field, then go back and have whatever results are pulled formatted appropriately?
Hi Behest,
Did you try the code that I posted? It worked for me on a Excel 2007 file.
- Ardhendu
Did you try the code that I posted? It worked for me on a Excel 2007 file.
- Ardhendu
I am doing my tests in 2007. No issues.
What is the error?
Kevin
What is the error?
Kevin
Try using ThisWorkbook instead of ActiveWorkbook:
ActiveSheet.PageSetup.Righ tFooter = "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
Kevin
ActiveSheet.PageSetup.Righ
Kevin
Better still, reference the specific worksheet:
ThisWorkbook.ActiveSheet.P ageSetup.R ightFooter = "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
Kevin
ThisWorkbook.ActiveSheet.P
Kevin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok...if I do a very basic script:
Sub mine()
With ActiveSheet.PageSetup
.RightFooter = ActiveWorkbook.Keywords
End With
End Sub
the result is whatever data has been added to the Document Properties keywords field.
I've tried each of your suggestions provided and the keywords field is not returned using these methods.
Sub mine()
With ActiveSheet.PageSetup
.RightFooter = ActiveWorkbook.Keywords
End With
End Sub
the result is whatever data has been added to the Document Properties keywords field.
I've tried each of your suggestions provided and the keywords field is not returned using these methods.
Use syntax:
ThisWorkbook.ActiveSheet.P ageSetup.R ightFooter = "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
Kevin
ThisWorkbook.ActiveSheet.P
Kevin
ASKER
Tried it...results in a blank right footer.
First try, I set up a new sub and pasted in the code. blank...
Second try, I broke it into a With statement...
Sub kevin3()
With ThisWorkbook.ActiveSheet.P ageSetup
RightFooter = "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
End With
End Sub
Again, blank.
So I pulled out the formatting detail...
Sub kevin3()
With ThisWorkbook.ActiveSheet.P ageSetup
.RightFooter = ThisWorkbook.Keywords
End With
End Sub
And the keywords data shows up in the footer.
Question 1...do you have the keywords field populated?
Question 2...is there a way to format the variable results after the fact?
Question 3...Why me?
First try, I set up a new sub and pasted in the code. blank...
Second try, I broke it into a With statement...
Sub kevin3()
With ThisWorkbook.ActiveSheet.P
RightFooter = "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
End With
End Sub
Again, blank.
So I pulled out the formatting detail...
Sub kevin3()
With ThisWorkbook.ActiveSheet.P
.RightFooter = ThisWorkbook.Keywords
End With
End Sub
And the keywords data shows up in the footer.
Question 1...do you have the keywords field populated?
Question 2...is there a way to format the variable results after the fact?
Question 3...Why me?
OK, this is weird. You sure you are not on a Mac?
Try this:
Dim Text As String
Debug.Print "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
Debug.Print "&""Times New Roman,Regular""&8"
Debug.Print ThisWorkbook.Keywords
Text = "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
Debug.Print Text
Debug.Print "" & ThisWorkbook.Keywords
Debug.Print "x" & ThisWorkbook.Keywords
Tell me what gets dumped.
Kevin
Try this:
Dim Text As String
Debug.Print "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
Debug.Print "&""Times New Roman,Regular""&8"
Debug.Print ThisWorkbook.Keywords
Text = "&""Times New Roman,Regular""&8" & ThisWorkbook.Keywords
Debug.Print Text
Debug.Print "" & ThisWorkbook.Keywords
Debug.Print "x" & ThisWorkbook.Keywords
Tell me what gets dumped.
Kevin
What, exactly, is in Keywords?
Kevin
Kevin
ASKER
I just have some numbers in Keywords...specifically, 12121212 because I was practicing my counting. lol.
I'm not on a Mac, but I know how to work on them. Surely the computer can't detect that when I'm in this mode. who knows...
Set up your Dim text code as a separate sub and the footer is blank in print preview and when I print to a pdf.
What should I have seen?
I'm not on a Mac, but I know how to work on them. Surely the computer can't detect that when I'm in this mode. who knows...
Set up your Dim text code as a separate sub and the footer is blank in print preview and when I print to a pdf.
What should I have seen?
Mac - that was a joke dude!
So does the code work if you put in something like "abc, def, xyz" for the keywords?
Kevin
So does the code work if you put in something like "abc, def, xyz" for the keywords?
Kevin
ASKER
All better!!! Kevin, thank you for your patience, knowledge, and humor.
It just occurred to me that one of the Add-Ins I have was active and possibly causing the conflict. Something in there conflicted with your code. So I de-activated it and my world is a much happier place.
Thank you VERY much!
It just occurred to me that one of the Add-Ins I have was active and possibly causing the conflict. Something in there conflicted with your code. So I de-activated it and my world is a much happier place.
Thank you VERY much!
ASKER
Thought I'd post a follow-up that deals with how Excel treats numbers in a Document Property field. The results I was trying to pull will all be numeric. When tested, the point size of the field results in the footer was something like 300 pts. The quick answer was to add a space to the front of the keywords field (i.e., "12345" becomes " 12345".
Since this will be applied to thousands of files, I ended up add a space to another of the Document Property fields and pulling both of them in the footer. Looks like this...
Sub CombProp()
ActiveWorkbook.BuiltinDocu mentProper ties("Cate gory").Val ue = " "
With ActiveSheet.PageSetup
.LeftFooter = "&""Times New Roman,Regular""&8" & _
ActiveWorkbook.BuiltinDocu mentProper ties("Cate gory") & _
ActiveWorkbook.BuiltinDocu mentProper ties("Keyw ords")
End With
End Sub
Since this will be applied to thousands of files, I ended up add a space to another of the Document Property fields and pulling both of them in the footer. Looks like this...
Sub CombProp()
ActiveWorkbook.BuiltinDocu
With ActiveSheet.PageSetup
.LeftFooter = "&""Times New Roman,Regular""&8" & _
ActiveWorkbook.BuiltinDocu
ActiveWorkbook.BuiltinDocu
End With
End Sub
ActiveSheet.PageSetup.Righ
Kevin