Access to Word not saving
I posted this on one other forum and haven't heard much but I'm very confused.
I have an Access database that I wanted to use just to format a list of files in a folder. All I really want to do is change the margin size and then save the document. However multiple attempts have failed. The code runs, the immediate window shows the file name as it's looping through the folder and I don't get error messages but the margins are never changed. What's the best way to do this?
This particular attempt I created with the macro recorder but I tried similar attempts that did not help.
Becky
================================================== =============
{code}
Option Compare Database
Sub BeckyTest()
Dim wordapp As Word.Application
Dim fs, fsFolder, fsFile, fsListOfFiles
Dim strFilename As String, strSQL As String
On Error Resume Next
Set wordapp = GetObject(, "Word.Application")
Set fs = CreateObject("Scripting.FileSystemObject")
Set fsFolder = fs.GetFolder("C:\Documents and Settings\bmcellis\Desktop\QuarterlyRptMacro")
Set fsListOfFiles = fsFolder.files
For Each fsFile In fsListOfFiles
wordapp.Documents.Open fsFile
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(1.5)
.BottomMargin = InchesToPoints(1.5)
.LeftMargin = InchesToPoints(0.25)
.RightMargin = InchesToPoints(0.2083)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With
fsFile.Save
wordapp.Documents.Close fsFile
Next
Set wordapp = Nothing
Openword:
Set wordapp = CreateObject("Word.Application")
Resume Next
MsgBox "done"
End Sub
{/code]
I've tried activedocument.save and fsfile.save both in the same code. I also tried commenting out fsfile.save and using activedocument.save instead but changes are not getting saved.
Other suggestions?
The code runs, I even see the name of the file in the debug window but the changes are not saved.
BeckyMack
|