![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
I am having trouble changing the style of a field in the header/footer
without it affecting the style of the text that was already in the header/footer. When I insert the field before the existing text, the style changes perfectly fine... range = section.Headers(wdHeaderFooterPrimary).range range.InsertBefore("IF PAGE = NUMPAGES ""Hello World" & vbcrlf & """) range.SetRange(rangeEndBeforeInsert, range.End) range.Fields.Add(range, wdFieldEmpty, , False) range.SetRange(rangeEndBeforeInsert, range.End) range.Style = word.ActiveDocument.Styles("Style") However, when I insert the field at the end of the range, set the range's boundaries to the field, and change the style, it also changes the style of the text at the beginning of the header/footer... range = section.Headers(wdHeaderFooterPrimary).range range.InsertAfter("IF PAGE = NUMPAGES """ & vbcrlf & "Hello World""") range.SetRange(rangeEndBeforeInsert, range.End) range.Fields.Add(range, wdFieldEmpty, , False) range.SetRange(rangeEndBeforeInsert, range.End) range.Style = word.ActiveDocument.Styles("Style") Again, the code works perfectly fine for the InsertBefore, it's just when I insert the code after and I try to change the style, the text before the field is changed to that style too. I wrote the code here in VB, but it's the same with VB.net and VBA. Any suggestions? |
Ads |
#2
|
|||
|
|||
![]() Wouldn't that be a question to ask in a Word forum? -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Thu, 21 Aug 2008 11:46:03 -0700 schrieb SWT: I am having trouble changing the style of a field in the header/footer without it affecting the style of the text that was already in the header/footer. When I insert the field before the existing text, the style changes perfectly fine... range = section.Headers(wdHeaderFooterPrimary).range range.InsertBefore("IF PAGE = NUMPAGES ""Hello World" & vbcrlf & """) range.SetRange(rangeEndBeforeInsert, range.End) range.Fields.Add(range, wdFieldEmpty, , False) range.SetRange(rangeEndBeforeInsert, range.End) range.Style = word.ActiveDocument.Styles("Style") However, when I insert the field at the end of the range, set the range's boundaries to the field, and change the style, it also changes the style of the text at the beginning of the header/footer... range = section.Headers(wdHeaderFooterPrimary).range range.InsertAfter("IF PAGE = NUMPAGES """ & vbcrlf & "Hello World""") range.SetRange(rangeEndBeforeInsert, range.End) range.Fields.Add(range, wdFieldEmpty, , False) range.SetRange(rangeEndBeforeInsert, range.End) range.Style = word.ActiveDocument.Styles("Style") Again, the code works perfectly fine for the InsertBefore, it's just when I insert the code after and I try to change the style, the text before the field is changed to that style too. I wrote the code here in VB, but it's the same with VB.net and VBA. Any suggestions? |
#3
|
|||
|
|||
![]()
Yep, I caught that after I posted it. Sorry for the confusion.
"Michael Bauer [MVP - Outlook]" wrote: Wouldn't that be a question to ask in a Word forum? -- Best regards Michael Bauer - MVP Outlook : VBOffice Reporter for Data Analysis & Reporting : Outlook Categories? Category Manager Is Your Tool : http://www.vboffice.net/product.html?pub=6&lang=en Am Thu, 21 Aug 2008 11:46:03 -0700 schrieb SWT: I am having trouble changing the style of a field in the header/footer without it affecting the style of the text that was already in the header/footer. When I insert the field before the existing text, the style changes perfectly fine... range = section.Headers(wdHeaderFooterPrimary).range range.InsertBefore("IF PAGE = NUMPAGES ""Hello World" & vbcrlf & """) range.SetRange(rangeEndBeforeInsert, range.End) range.Fields.Add(range, wdFieldEmpty, , False) range.SetRange(rangeEndBeforeInsert, range.End) range.Style = word.ActiveDocument.Styles("Style") However, when I insert the field at the end of the range, set the range's boundaries to the field, and change the style, it also changes the style of the text at the beginning of the header/footer... range = section.Headers(wdHeaderFooterPrimary).range range.InsertAfter("IF PAGE = NUMPAGES """ & vbcrlf & "Hello World""") range.SetRange(rangeEndBeforeInsert, range.End) range.Fields.Add(range, wdFieldEmpty, , False) range.SetRange(rangeEndBeforeInsert, range.End) range.Style = word.ActiveDocument.Styles("Style") Again, the code works perfectly fine for the InsertBefore, it's just when I insert the code after and I try to change the style, the text before the field is changed to that style too. I wrote the code here in VB, but it's the same with VB.net and VBA. Any suggestions? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I print email without the date on the header and footer? | win | Outlook - General Queries | 1 | September 2nd 07 02:52 AM |
Header & Footer | David French | Outlook - Calandaring | 1 | August 25th 06 06:45 PM |
VBA code to populate an email header and footer | marie | Outlook and VBA | 1 | July 28th 06 04:21 AM |
Word Reference header/footer files | Mr. Esteban | Outlook and VBA | 1 | May 27th 06 12:35 PM |
Changing calendar header and or footer | Denisa | Outlook - Calandaring | 0 | May 10th 06 04:03 PM |