VisualBasicHelp
Programmer
I am trying to create a macro which gives me different headers on different pages. But when I am trying to add a new header in the 3rd page , that is, if the first 2 pages are section 1 and 3rd page is section 2 . It is making the changes in section 1 and not in section 2. Can anybody please help me out. I am just messed up with that.
If I do it directly without macro, I am able to do it. For reference I am pasting my code. Please refer to it.
'Creating a section in the next page
Selection.InsertBreak Type:=wdSectionBreakNextPage
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
'Making sure the page layout is printview
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
'Activating the header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
'Deleting everything
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, count:=1
'Formatting the text
Selection.Font.Size = 14
Selection.Font.Name = "Arial"
Selection.Font.Bold = True
'Typing in the header
Selection.TypeText Text:="TESTCASE : "
Selection.TypeParagraph
Selection.TypeText Text:="TEST STEP : " & teststep
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Thanks in advance
If I do it directly without macro, I am able to do it. For reference I am pasting my code. Please refer to it.
'Creating a section in the next page
Selection.InsertBreak Type:=wdSectionBreakNextPage
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
'Making sure the page layout is printview
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
'Activating the header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
'Deleting everything
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, count:=1
'Formatting the text
Selection.Font.Size = 14
Selection.Font.Name = "Arial"
Selection.Font.Bold = True
'Typing in the header
Selection.TypeText Text:="TESTCASE : "
Selection.TypeParagraph
Selection.TypeText Text:="TEST STEP : " & teststep
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Thanks in advance