![]() |
#1
|
|||
|
|||
![]() Hi there, I'm new to Word VBA, and it's a little alien to me... I want to be able to add the text of a combobox selection to the header of a document. Can anyone help? |
#2
|
||||
|
||||
![]()
Which header? Each Section of a document has three headers (and footers) - primary, first page and even, potentially giving many headers in a single document. At the most basic level, you'd populate the first Section's primary header with code like:
Code:
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "my text"
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Thanks for your response. The text would go on the headers of all the pages. Another question, is in the VBA Editor, I don't see a reference to any of the comboboxes I put into the form. If I were writing the code in Excel, I would put something like:
Range("A1").value = combobox1.value How is this overcome in Word? |
#4
|
||||
|
||||
![]()
As I said, the code I posted was fairly basic. Without knowing how many Sections your document has, or how many headers each Section uses and, if more than one, whether their headers are linked, I'd be reluctant to suggest anything more than:
Code:
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = Combobox1.Value
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tinfanide | Excel Programming | 2 | 10-13-2014 06:10 AM |
![]() |
ilcaa72 | Word VBA | 1 | 01-28-2014 03:04 PM |
![]() |
tinfanide | PowerPoint | 4 | 12-28-2012 06:14 PM |
How to pass parameters to a .msg file? | HereNow | Outlook | 0 | 11-05-2012 10:38 AM |
How to use the content of a combobox for {IF} field? | Melaanie | Word | 0 | 06-14-2010 02:00 AM |