Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2015, 12:04 AM
wpryan wpryan is offline Pass combobox content to header Windows 7 64bit Pass combobox content to header Office 2010 64bit
Novice
Pass combobox content to header
 
Join Date: Oct 2013
Location: Orlando, FL USA
Posts: 26
wpryan is on a distinguished road
Default Pass combobox content to header


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?
Reply With Quote
  #2  
Old 07-17-2015, 12:32 AM
macropod's Avatar
macropod macropod is offline Pass combobox content to header Windows 7 64bit Pass combobox content to header Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 07-17-2015, 12:59 AM
wpryan wpryan is offline Pass combobox content to header Windows 7 64bit Pass combobox content to header Office 2010 64bit
Novice
Pass combobox content to header
 
Join Date: Oct 2013
Location: Orlando, FL USA
Posts: 26
wpryan is on a distinguished road
Default

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?
Reply With Quote
  #4  
Old 07-17-2015, 01:44 AM
macropod's Avatar
macropod macropod is offline Pass combobox content to header Windows 7 64bit Pass combobox content to header Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass combobox content to header How to Pass Arguments in a Formula? tinfanide Excel Programming 2 10-13-2014 06:10 AM
Pass combobox content to header How to Pass Document to this Sub ilcaa72 Word VBA 1 01-28-2014 03:04 PM
Pass combobox content to header Can pass .expression as a parameter? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 12:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft