Creating headers using macros

R

Rick Tawney

I'm using Microsoft Word 2002 SP3 on XP to try and use macros to create
different headers within a document with, the user is prompted with MsgBox
for input. There seems to be two problems. 1) When I use a macro to go to the
current header ir does not. It may go to the last or the next header. 2) The
curser location in the header can not be controlled with a macro. When
instructed to go to the top then move down two lines it does not.

Any help would be appreciated.
 
R

Rick Tawney

Thanks for the try Jezebel, I tried your suggestion but I couldn’t get it to
work. I’m not that savvy with VB so that no doubt is a obstacle. For further
clarification I want to create a section break and then go to this new
section, there could be any number of sections in the document, prompt for
user input to create the new header then return to the body of the document
until the next new section needs to be created. Or create new headers for the
next section as you go along in the document. If I’m reading what you sent me
right it would work for section 3. I need to create new headers for each new
section.
 
R

Rick Tawney

I tried the last one with no sucess here is what I came up with. As you can
see the text from this macro is entered in the body and not the header of the
next section. help: thanks

With ActiveDocument
.Sections.Add Start:=wdSectionNewPage
With .Sections(.Sections.Count).Headers(wdHeaderFooterFirstPage)
.LinkToPrevious = False
.Range = "New header for first page of new section"
headervar = InputBox("1-Chapter 1 2-Chapter 2 3-Capter 3", "Header", 1)
Select Case headervar
Case "1"
Selection.TypeText Text:=" Chapter One "
Case "2"
Selection.TypeText Text:=" Chapter Two "
Case "3"
Selection.TypeText Text:=" Chapter Three "
End Select

End With
End With
 

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