Saveas method for word document fails

B

brockc

I have code that worked without problem in Access 2003 that no longer
works in Access 2007.

Dim WordObj As Word.Application
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Add strMemoTemplate
... code to populate document
WordObj..ActiveDocument.SaveAs strFileName

Results in a -2147417851 error that the Server threw an exception.

I rebuilt my PC and reinstall Office 2007 and the code work that day,
but just a few days later the code no longer works (I did not try
between then), getting that same error. I have replicated this on
other PCs.

I can set breaks and add code to see the document is created
properly. It just fails when you try to save it.

Thanks
Christian
 
A

Alex Dybenko

Hi,
you have 2 dots here:
WordObj..ActiveDocument.SaveAs strFileName

perhaps this is a problem?
you can also do like this:

dim wd as word.document
set wd=WordObj.Documents.Add (strMemoTemplate)
.... code to populate document
wd.SaveAs strFileName


--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
B

brockc

Thanks.

The 2 dots were just a typo.

I tried that code and I still get the error.

I don't think the problem is with the code as it did work for a time.
I think there is some Office 2007 update that is causing the problem
but I can't figure out what.
 
J

JvC

Christian,

This is not a problem I have seen in 2003 or 2007. What is the file
name you are using for strFileName? As this is a new computer, is there
a possibility there is an error in the path to strFileName, or to the
directory rights?

Good luck!

John

(e-mail address removed) was thinking very hard :
 
B

brockc

I managed to determine the problem was caused by an add-in (ApproveIt
Desktop). I can workaroudn the problem by going in to Word Options
and setting the add-in so it does not load when Word starts. When the
add-in is not loaded I don't get the error.
 

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