R
rog982001
I got MS Word to write a macro for me. It didn't work. The macro should
perform the following tasks on a merged document. The document is merged with
an Excel spreadsheet and an MS Word template. The fields on the Word document
are filled-in with the data from Excel. This part works just fine and creates
approximately 3,800 letters!
The MS Word macro must:
1. Save each letter in a separate file.
a. Pull the control number from each document.
b. Save each file as "CB xxx.doc" where xxx is the control number.
2. Advance to the next letter in the file.
3. Repeat steps (1) and (2).
This is the code that I have so far. If some one could expand on the hard
coded line:
RESEARCH_BEGINNING_DATE = "101"
The number 101 should be a variable not a constant.
Roger
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 3/28/2008 by Customer Services
'
Set myRange = ActiveDocument.Range(Start:=0, End:=1)
RESEARCH_BEGINNING_DATE = "101"
FileName = "Charge Back" & RESEARCH_BEGINNING_DATE & ".doc"
ActiveDocument.SaveAs FileName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
Selection.MoveDown Unit:=wdScreen, Count:=4
Selection.HomeKey Unit:=wdLine
End Sub
perform the following tasks on a merged document. The document is merged with
an Excel spreadsheet and an MS Word template. The fields on the Word document
are filled-in with the data from Excel. This part works just fine and creates
approximately 3,800 letters!
The MS Word macro must:
1. Save each letter in a separate file.
a. Pull the control number from each document.
b. Save each file as "CB xxx.doc" where xxx is the control number.
2. Advance to the next letter in the file.
3. Repeat steps (1) and (2).
This is the code that I have so far. If some one could expand on the hard
coded line:
RESEARCH_BEGINNING_DATE = "101"
The number 101 should be a variable not a constant.
Roger
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 3/28/2008 by Customer Services
'
Set myRange = ActiveDocument.Range(Start:=0, End:=1)
RESEARCH_BEGINNING_DATE = "101"
FileName = "Charge Back" & RESEARCH_BEGINNING_DATE & ".doc"
ActiveDocument.SaveAs FileName, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
Selection.MoveDown Unit:=wdScreen, Count:=4
Selection.HomeKey Unit:=wdLine
End Sub