Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 9th, 2008, 07:16 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Word file into Database melvik SQL Server 2000 4 November 28th, 2005 09:12 AM
Saving Word File In SQL Server abdul_wasie Classic ASP Databases 0 May 20th, 2005 06:05 AM
saving picture from word to other folder DorisTan VB How-To 0 December 3rd, 2004 02:46 AM
saving word document in server asp sdeep_us Classic ASP Basics 1 August 7th, 2004 10:30 PM
Saving Word file into Database melvik C# 0 March 8th, 2004 07:36 AM



All times are GMT -4. The time now is 12:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.