Remote Server error

J

JWS315

I am using the code below in Access to create a Word document, 1st time it
works fine, 2nd time I get an error that it cannot find the remote server. I
get it on the line wdApp.ActiveDocument.PageSetup.LeftMargin =
InchesToPoints(0.5). Any suggestion will be greatly appreciated!

Jerry

Dim wdApp As Object
Dim docFinal As Object

' Create new hidden instance of Word.
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
Set docFinal = wdApp.Documents.Add
docFinal.PageSetup.Orientation = wdOrientPortrait
docFinal.PageSetup.DifferentFirstPageHeaderFooter = False
docFinal.SaveAs FileName:="" & wdFname & "", FileFormat:=wdWordDocument
'Activate the current window
tmpFinalDoc = GetFileName(wdFname)
wdApp.Windows(tmpFinalDoc).Activate
wdApp.ActiveDocument.PageSetup.LeftMargin = InchesToPoints(0.5)
wdApp.ActiveDocument.PageSetup.RightMargin = InchesToPoints(0.5)
wdApp.ActiveDocument.PageSetup.TopMargin = InchesToPoints(0.5)
wdApp.ActiveDocument.PageSetup.BottomMargin = InchesToPoints(0.5)
......
'Save the document and close
docFinal.SaveAs FileName:="" & wdFname & "", FileFormat:=wdWordDocument
docFinal.Close
wdApp.Quit wdDoNotSaveChanges
Set docFinal = Nothing
Set wdApp = Nothing
 
W

Word Heretic

G'day JWS315 <[email protected]>,

wdApp.ActiveDocument.PageSetup is your problem

iterate through the wdApp.ActiveDocument.SECTIONS(n).PageSetup


Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


JWS315 reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top