garethtaylor
12-18-2009, 04:39 AM
Hi all,
I have this code I recorded from a macro and copied into the command button.
It opens a letter template (C1) it then goes back to the loader document with the command button, copies something then goes back to the letter template (C1) then pastes this information it does this 3 times.
The problem is that the documents are templates therefore once the document is open it is no longer the same name it will be document 1, document 2, etc depending how many other documents the user has open therefore the code stops as the file name it is looking for does not exists
What I was wanting help with is what code and where should I put it for the below code?
It needs to find the correct name for the loader document, the one with the command button so it can go back to it once it has opened the letter template.
Also
Need to find the name of the letter template (c1) so it can find and go back to paste the information onto the document.
Here is the code I have, for ease I have highlighted the names of the documents in bold
For reference the document with eh code is called “letterloader” & the document it opens is called “C1”
ChangeFileOpenDirectory "O:\In development - not to be used yet\Master Documents\Master Letter Templates\"
Documents.Open FileName:="C1.dot", ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto
Windows("letter loader").Activate
ActiveDocument.Shapes("Text Box 19").Select
Selection.WholeStory
Selection.Copy
Windows("C1").Activate
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.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Windows("letter loader").Activate
Selection.ShapeRange.Select
ActiveDocument.Shapes("Text Box 2").Select
Selection.WholeStory
Selection.Copy
Windows("C1").Activate
Selection.MoveDown Unit:=wdLine, Count:=53
Selection.MoveUp Unit:=wdLine, Count:=14
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
ActiveWindow.ActivePane.VerticalPercentScrolled = 21
Windows("letter loader").Activate
Selection.ShapeRange.Select
ActiveDocument.Shapes("Text Box 9").Select
Selection.WholeStory
Selection.Copy
Windows("C1").Activate
Selection.Paste
sorry forgot to say this MS Word 2000
I have this code I recorded from a macro and copied into the command button.
It opens a letter template (C1) it then goes back to the loader document with the command button, copies something then goes back to the letter template (C1) then pastes this information it does this 3 times.
The problem is that the documents are templates therefore once the document is open it is no longer the same name it will be document 1, document 2, etc depending how many other documents the user has open therefore the code stops as the file name it is looking for does not exists
What I was wanting help with is what code and where should I put it for the below code?
It needs to find the correct name for the loader document, the one with the command button so it can go back to it once it has opened the letter template.
Also
Need to find the name of the letter template (c1) so it can find and go back to paste the information onto the document.
Here is the code I have, for ease I have highlighted the names of the documents in bold
For reference the document with eh code is called “letterloader” & the document it opens is called “C1”
ChangeFileOpenDirectory "O:\In development - not to be used yet\Master Documents\Master Letter Templates\"
Documents.Open FileName:="C1.dot", ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto
Windows("letter loader").Activate
ActiveDocument.Shapes("Text Box 19").Select
Selection.WholeStory
Selection.Copy
Windows("C1").Activate
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.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Windows("letter loader").Activate
Selection.ShapeRange.Select
ActiveDocument.Shapes("Text Box 2").Select
Selection.WholeStory
Selection.Copy
Windows("C1").Activate
Selection.MoveDown Unit:=wdLine, Count:=53
Selection.MoveUp Unit:=wdLine, Count:=14
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Paste
ActiveWindow.ActivePane.VerticalPercentScrolled = 21
Windows("letter loader").Activate
Selection.ShapeRange.Select
ActiveDocument.Shapes("Text Box 9").Select
Selection.WholeStory
Selection.Copy
Windows("C1").Activate
Selection.Paste
sorry forgot to say this MS Word 2000