L
LEU
I have 2 macros that are conflicting with each other. The first one deletes
the last page of the template if it’s not required. Then I just added the
second macro in the ThisDocument that opens up a form if the user tries to
edit the header. Now that I have done this the first macro no longer workers
because part of the macro is to delete the header from the last page. Is
there a way to work around this? My macros are as follows:
Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
'quit if active doc isn't attached to this template
If ActiveDocument.AttachedTemplate <> ThisDocument Then Exit Sub
'get out of the header if we're in it
Select Case Sel.StoryType
Case wdEvenPagesHeaderStory, wdFirstPageHeaderStory, wdPrimaryHeaderStory
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
frmTable.Show
Exit Sub
Case Else
If Sel.Range.InRange(ActiveDocument.Bookmarks("bktable").Range) Then
ActiveDocument.Bookmarks("bkbeforetbl").Select
frmTable.Show
End If
End Select
End Sub
Sub DeleteLastPage()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you sure you want to delete Templates last page?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Deletion Confirmation"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
Selection.EndKey unit:=wdStory
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveWindow.ActivePane.SmallScroll Down:=-18
Selection.MoveUp unit:=wdScreen, Count:=1
ActiveWindow.ActivePane.VerticalPercentScrolled = 63
Selection.Delete unit:=wdCharacter, Count:=1
Selection.Delete unit:=wdCharacter, Count:=1
With Selection.PageSetup
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.75)
.BottomMargin = InchesToPoints(0.75)
.LeftMargin = InchesToPoints(0.8)
.RightMargin = InchesToPoints(0.8)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
End With
Selection.Delete unit:=wdCharacter, Count:=6
Else
MyString = "No"
End If
End Sub
LEU
the last page of the template if it’s not required. Then I just added the
second macro in the ThisDocument that opens up a form if the user tries to
edit the header. Now that I have done this the first macro no longer workers
because part of the macro is to delete the header from the last page. Is
there a way to work around this? My macros are as follows:
Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
'quit if active doc isn't attached to this template
If ActiveDocument.AttachedTemplate <> ThisDocument Then Exit Sub
'get out of the header if we're in it
Select Case Sel.StoryType
Case wdEvenPagesHeaderStory, wdFirstPageHeaderStory, wdPrimaryHeaderStory
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
frmTable.Show
Exit Sub
Case Else
If Sel.Range.InRange(ActiveDocument.Bookmarks("bktable").Range) Then
ActiveDocument.Bookmarks("bkbeforetbl").Select
frmTable.Show
End If
End Select
End Sub
Sub DeleteLastPage()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you sure you want to delete Templates last page?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Deletion Confirmation"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then
Selection.EndKey unit:=wdStory
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
LinkToPrevious
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
ActiveWindow.ActivePane.SmallScroll Down:=-18
Selection.MoveUp unit:=wdScreen, Count:=1
ActiveWindow.ActivePane.VerticalPercentScrolled = 63
Selection.Delete unit:=wdCharacter, Count:=1
Selection.Delete unit:=wdCharacter, Count:=1
With Selection.PageSetup
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.75)
.BottomMargin = InchesToPoints(0.75)
.LeftMargin = InchesToPoints(0.8)
.RightMargin = InchesToPoints(0.8)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
End With
Selection.Delete unit:=wdCharacter, Count:=6
Else
MyString = "No"
End If
End Sub
LEU