TeeBeeOz
07-03-2011, 07:17 PM
Hello
Firstly, apologies upfront for being a VBA dummy!
Issue:
We have successfully used a macro I believe was originally created using Word 98 VBA in Word 2003. After migrating to MS Office 2007, the same macro no longer 100% works, ie it just fails on the last part of the process.
Simply, the macro copies text seleted by the user into the Page 2+ header section of our letter documents. Part of this involves inserting a page break (to access the 2+ header section), copying the selected text into the header and then removing the page break inserted earlier in the macro .... it is the last part of the process that no longer works, ie so the user is left with a page break (and an unwanted page) at the end of their letter. Here's the code:
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.InsertBreak Type:=wdPageBreak
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
' get into the header for this page (2+) and paste the text - no
' formatting hence paste special. This text is pasted at LHS - assumes
' other required information has been put in the header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
' back to main document and remove additional hard page
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.TypeBackspace
I've tried re-creating the macro from scratch in Word 2007, but still can't get it to work properly. Any assistance would be greatly appreciated ... :yes
Firstly, apologies upfront for being a VBA dummy!
Issue:
We have successfully used a macro I believe was originally created using Word 98 VBA in Word 2003. After migrating to MS Office 2007, the same macro no longer 100% works, ie it just fails on the last part of the process.
Simply, the macro copies text seleted by the user into the Page 2+ header section of our letter documents. Part of this involves inserting a page break (to access the 2+ header section), copying the selected text into the header and then removing the page break inserted earlier in the macro .... it is the last part of the process that no longer works, ie so the user is left with a page break (and an unwanted page) at the end of their letter. Here's the code:
Selection.Copy
Selection.EndKey Unit:=wdStory
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.InsertBreak Type:=wdPageBreak
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
' get into the header for this page (2+) and paste the text - no
' formatting hence paste special. This text is pasted at LHS - assumes
' other required information has been put in the header
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
' back to main document and remove additional hard page
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.TypeBackspace
I've tried re-creating the macro from scratch in Word 2007, but still can't get it to work properly. Any assistance would be greatly appreciated ... :yes