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
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