Hi,

I'm using Word97 and have approx 100 unformatted text files in the following
directory

\\FINPC13\SHARE FIN01\NR6 Draft .rpt\

I want to open each in turn, perform identical formatting on each file and
then save the file as a word document within the same directory.
The following programming performs the first part of this routine (I think!)

Sub RunNR6()

Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document

PathToUse = "\\FINPC13\SHARE FIN01\NR6 Draft .rpt\"

myFile = Dir$(PathToUse & "*.rpt")

While myFile <> ""

Set myDoc = Documents.Open(PathToUse & myFile)

Selection.WholeStory
Selection.Font.Size = 8
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = InchesToPoints(0.5)
.BottomMargin = InchesToPoints(0.5)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(0.5)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(11.69)
.PageHeight = InchesToPoints(8.27)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
End With


I am struggling with the code which will then save each file (the active
document at the time) as a fully formatted word document within the following
directory:-

\\FINPC13\SHARE FIN01\NR6 Draft .rpt\

Help gratefully appreciated.

Graham

Re: Programming Re Document Save by Jonathan

Jonathan
Wed Jul 20 11:13:39 CDT 2005

Hi Graham,

Look up the SaveAs method of the Document object. You would need to add
something like this to your macro


myFile = Left$(myFile, Len(myFile) - 3) & "doc"
ActiveDocument.SaveAs FileName:=myFile, FileFormat:=wdFormatDocument
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

"Graham L" <GrahamL@discussions.microsoft.com> wrote in message
news:B1C63222-205D-4F7E-A157-0A33DC942CD0@microsoft.com...
> Hi,
>
> I'm using Word97 and have approx 100 unformatted text files in the
> following
> directory
>
> \\FINPC13\SHARE FIN01\NR6 Draft .rpt\
>
> I want to open each in turn, perform identical formatting on each file and
> then save the file as a word document within the same directory.
> The following programming performs the first part of this routine (I
> think!)
>
> Sub RunNR6()
>
> Dim myFile As String
> Dim PathToUse As String
> Dim myDoc As Document
>
> PathToUse = "\\FINPC13\SHARE FIN01\NR6 Draft .rpt\"
>
> myFile = Dir$(PathToUse & "*.rpt")
>
> While myFile <> ""
>
> Set myDoc = Documents.Open(PathToUse & myFile)
>
> Selection.WholeStory
> Selection.Font.Size = 8
> With ActiveDocument.PageSetup
> .LineNumbering.Active = False
> .Orientation = wdOrientLandscape
> .TopMargin = InchesToPoints(0.5)
> .BottomMargin = InchesToPoints(0.5)
> .LeftMargin = InchesToPoints(1)
> .RightMargin = InchesToPoints(0.5)
> .Gutter = InchesToPoints(0)
> .HeaderDistance = InchesToPoints(0.5)
> .FooterDistance = InchesToPoints(0.5)
> .PageWidth = InchesToPoints(11.69)
> .PageHeight = InchesToPoints(8.27)
> .FirstPageTray = wdPrinterDefaultBin
> .OtherPagesTray = wdPrinterDefaultBin
> .SectionStart = wdSectionNewPage
> .OddAndEvenPagesHeaderFooter = False
> .DifferentFirstPageHeaderFooter = False
> .VerticalAlignment = wdAlignVerticalTop
> .SuppressEndnotes = False
> .MirrorMargins = False
> End With
>
>
> I am struggling with the code which will then save each file (the active
> document at the time) as a fully formatted word document within the
> following
> directory:-
>
> \\FINPC13\SHARE FIN01\NR6 Draft .rpt\
>
> Help gratefully appreciated.
>
> Graham
>
>
>
>
>


Re: Programming Re Document Save by FLConsultant

FLConsultant
Fri Jul 22 02:58:01 CDT 2005

Jonathan,

Would you look at my post How to update mailmergefields and MailMerge Doc
with VBA. I would appreciate some additional input and suggestions.

Thank you
--
FL Consultant


"Jonathan West" wrote:

> Hi Graham,
>
> Look up the SaveAs method of the Document object. You would need to add
> something like this to your macro
>
>
> myFile = Left$(myFile, Len(myFile) - 3) & "doc"
> ActiveDocument.SaveAs FileName:=myFile, FileFormat:=wdFormatDocument
> ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>
> "Graham L" <GrahamL@discussions.microsoft.com> wrote in message
> news:B1C63222-205D-4F7E-A157-0A33DC942CD0@microsoft.com...
> > Hi,
> >
> > I'm using Word97 and have approx 100 unformatted text files in the
> > following
> > directory
> >
> > \\FINPC13\SHARE FIN01\NR6 Draft .rpt\
> >
> > I want to open each in turn, perform identical formatting on each file and
> > then save the file as a word document within the same directory.
> > The following programming performs the first part of this routine (I
> > think!)
> >
> > Sub RunNR6()
> >
> > Dim myFile As String
> > Dim PathToUse As String
> > Dim myDoc As Document
> >
> > PathToUse = "\\FINPC13\SHARE FIN01\NR6 Draft .rpt\"
> >
> > myFile = Dir$(PathToUse & "*.rpt")
> >
> > While myFile <> ""
> >
> > Set myDoc = Documents.Open(PathToUse & myFile)
> >
> > Selection.WholeStory
> > Selection.Font.Size = 8
> > With ActiveDocument.PageSetup
> > .LineNumbering.Active = False
> > .Orientation = wdOrientLandscape
> > .TopMargin = InchesToPoints(0.5)
> > .BottomMargin = InchesToPoints(0.5)
> > .LeftMargin = InchesToPoints(1)
> > .RightMargin = InchesToPoints(0.5)
> > .Gutter = InchesToPoints(0)
> > .HeaderDistance = InchesToPoints(0.5)
> > .FooterDistance = InchesToPoints(0.5)
> > .PageWidth = InchesToPoints(11.69)
> > .PageHeight = InchesToPoints(8.27)
> > .FirstPageTray = wdPrinterDefaultBin
> > .OtherPagesTray = wdPrinterDefaultBin
> > .SectionStart = wdSectionNewPage
> > .OddAndEvenPagesHeaderFooter = False
> > .DifferentFirstPageHeaderFooter = False
> > .VerticalAlignment = wdAlignVerticalTop
> > .SuppressEndnotes = False
> > .MirrorMargins = False
> > End With
> >
> >
> > I am struggling with the code which will then save each file (the active
> > document at the time) as a fully formatted word document within the
> > following
> > directory:-
> >
> > \\FINPC13\SHARE FIN01\NR6 Draft .rpt\
> >
> > Help gratefully appreciated.
> >
> > Graham
> >
> >
> >
> >
> >
>
>