M
Mike Wood
I have a macro that I run once per document. The macro pulls in a
text report file and changes the font and orientation, then asks the
directory I want to save the new document in and then the document
name.
These reports are downloaded from a mainframe and then saved as
archive reports for users to refer to at a later date. I usually am
processing 200-300 reports at a time every 3-4 months.
This is a highly repetitive task which is why I created the macro.
On my previous computer, using Word 2000, I was able to keep the
directory name and the filename from instance to instance; only
changing when I need to change the output directory or the filename.
On my new computer running Word 2002 I have been unable to get the
variables to be static.
What am I doing wrong?
Static Sub report()
'
' report Macro
' Macro recorded 10/30/2003 by Mike Wood
'
Static dirname As String
Static filname As String
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = InchesToPoints(0.5)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(11)
.PageHeight = InchesToPoints(8.5)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With
Selection.WholeStory
Selection.font.Name = "Courier New"
'Selection.font.Name = "Courier New"
Selection.font.Size = 8
dirname = InputBox("Please supply directory name for save", "Enter
Directory Name")
ChangeFileOpenDirectory ("K:\FINSRV\BILLING\reports\" & dirname)
filname = InputBox("Please supply file name for save", "Enter
Document Name")
ActiveDocument.SaveAs filename:=filname, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub
text report file and changes the font and orientation, then asks the
directory I want to save the new document in and then the document
name.
These reports are downloaded from a mainframe and then saved as
archive reports for users to refer to at a later date. I usually am
processing 200-300 reports at a time every 3-4 months.
This is a highly repetitive task which is why I created the macro.
On my previous computer, using Word 2000, I was able to keep the
directory name and the filename from instance to instance; only
changing when I need to change the output directory or the filename.
On my new computer running Word 2002 I have been unable to get the
variables to be static.
What am I doing wrong?
Static Sub report()
'
' report Macro
' Macro recorded 10/30/2003 by Mike Wood
'
Static dirname As String
Static filname As String
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = InchesToPoints(0.5)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(11)
.PageHeight = InchesToPoints(8.5)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With
Selection.WholeStory
Selection.font.Name = "Courier New"
'Selection.font.Name = "Courier New"
Selection.font.Size = 8
dirname = InputBox("Please supply directory name for save", "Enter
Directory Name")
ChangeFileOpenDirectory ("K:\FINSRV\BILLING\reports\" & dirname)
filname = InputBox("Please supply file name for save", "Enter
Document Name")
ActiveDocument.SaveAs filename:=filname, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub