Text inside a Textbox, inside a Header

0

01dap

Hi
Our company resumes use headers, inside the header is a
text box with the employee name. I'm trying to write a
macro to copy the name from inside the textbox that is in
the header. The text must be inserted at the beginning of
the document.

Recording a macro does not allow you to select the text
box so I can't find the object.

Thanks Don
 
P

Peter Hewett

Hi 01dap

Word has 3 different Header/Footer types, so I'll assume you're using the default
Header/Footer. Also, each Section of your document can have it's own set of
Headers/Footers, so again I'll assume you mean the first Section of your document.

TextBoxes are by default members of a Word Shapes collection (I'll not make things even
more complex for you by delving into InlineShapes). If possible it's best to name the
shape so that you can guarantee you're working with the correct object, if your header
contains a logo or some other graphic this could occur.

Anyway, here how to do it:


ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes(1).TextFrame.TextRange.Text

HTH + Cheers - Peter


Hi
Our company resumes use headers, inside the header is a
text box with the employee name. I'm trying to write a
macro to copy the name from inside the textbox that is in
the header. The text must be inserted at the beginning of
the document.

Recording a macro does not allow you to select the text
box so I can't find the object.

Thanks Don

HTH + Cheers - Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top