PDA

View Full Version : Help on looping macro code and not repeating myself



windowsxprel
05-22-2014, 06:30 PM
I am working on the following macro code, but I have to constantly repeat myself because I don't know an easier way. Can someone please look at this code and help me. I would really appreciate the help! I have been going at this for weeks, and I can't find a solution.


' FILE NAME = LoQUo_01_01_d
ActiveDocument.SaveAs2 FileName:="LoQUo_01_01_d.iim", FileFormat:= _
wdFormatText, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=msoEncodingUTF8, InsertLineBreaks:=False, AllowSubstitutions:=False _
, LineEnding:=wdCRLF, CompatibilityMode:=0

' NEXT MACROS
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord

' FILE NAME = LoQUo_01_02_d
ActiveDocument.SaveAs2 FileName:="LoQUo_01_02_d.iim", FileFormat:= _
wdFormatText, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=msoEncodingUTF8, InsertLineBreaks:=False, AllowSubstitutions:=False _
, LineEnding:=wdCRLF, CompatibilityMode:=0

' NEXT MACROS
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord

' FILE NAME = LoQUo_02_01_d
ActiveDocument.SaveAs2 FileName:="LoQUo_02_01_d.iim", FileFormat:= _
wdFormatText, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=msoEncodingUTF8, InsertLineBreaks:=False, AllowSubstitutions:=False _
, LineEnding:=wdCRLF, CompatibilityMode:=0

' NEXT MACROS
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord

' FILE NAME = LoQUo_02_02_d
ActiveDocument.SaveAs2 FileName:="LoQUo_02_02_d.iim", FileFormat:= _
wdFormatText, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=msoEncodingUTF8, InsertLineBreaks:=False, AllowSubstitutions:=False _
, LineEnding:=wdCRLF, CompatibilityMode:=0

macropod
05-23-2014, 03:17 AM
Cross-posted at: http://www.excelforum.com/word-programming-vba-macros/1013147-help-on-looping-macro-code-and-not-repeating-myself.html#post3706981
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184