P
P.Schuman
Running Access 2007 with SharePoint MOSS 2007
Here is a message from a biz friend that has created an invoicing system
using Access 2007 on the local PC, and SharePoint 2007 on the remote server
for file storage.
--
Here is a precise description of the problem.... any URL's have been
sanitized for public reading -
The routine which is enclosed is an Access 2007 routine that launches Word
2007 from within Access Visual Basic.
· It creates a late binding instance of MS Word 2007 from MS ACCESS
2007.
· When the program begins it tries to use GetObject(,"word.Application)
to see if there is an existing instance of word to use.
· If an error occurs, it then uses CreateObject ("word.application")
to launch word. Here is the relevant code:
Set wordobj = GetObject(, "word.application")
If Err.number <> 0 Then
'An error is thrown if word is not running
' So use create object to start word
Set wordobj = CreateObject("word.application")
MsgBox "CreateObject was used"
End If
wordobj.Documents.Add _
Template:="https://sharepoint.xyz.com/ClientInvoices/Invoice-Template/Invoice-Template.dotx",
Newtemplate:=False, Visible:=True
wordobj.Visible = True
· A template is populated with a series of bookmarks based on some
fields from an access data base. This is rather simple and works fine.
· Finally the file is saved using the following two commands. The
first line simply creates a file name. The second line does the save.
filename = "https://sharepoint.xyz.com/ClientInvoices/Invoices/" &
Me.txtNewInvoiceNumber & "-" & Me.txtProject & "-" & Format(Now(),
"mm-dd-yyyy-hh-mm") & ".doc"
ActiveDocument.SaveAs filename:=filename, FileFormat:=wdFormatDocument97
· THIS WORKS PERFECTLY SO LONG AS I DON"T CLOSE WORD.
It will save files over and over per the logic it follows.
Let me repeat - I CAN RUN THIS CODE PERFECTLY A MILLION TIMES SO LONG AS I
DON'T CLOSE WORD.
· HOWEVER IF I ADD THE FOLLOWING COMMAND AT THE END OF THE MODULE
THE CODE FAILS to SAVE. AND I DON"T THINK IT IS THE CODE, BUT MS OFFICE.
wordobj.Quit
· By adding a quit command, MS word ends and must be restarted by
the code.
· If word closes - either through the user closing it or through
this command,
the new instance of WORD created the next time the code is run, -> fails to
Save the document.
· The WORD DOCUMENT file is successfully opened,
the DOCUMENT fields filled in and the word document is fine,
BUT IT WILL NOT SAVE. THE SAVE SUDDENLY FAILS. AND FAILS EVERY TIME.
o As I test it, I get the following system error after the save attempt:
"462 - The remote machine does not exist or is unavailable"
· This should not occur. Yet it does. It appears that when the
access code tries to reestablish the connection to the Word instance, but
it has issues that are not user issues. It executes the createobject and
launches word fine, fills in the document but FAILS the SAVE.
My question is simple - WHY??????? AND HOW DO I FIX THIS.
Here is a message from a biz friend that has created an invoicing system
using Access 2007 on the local PC, and SharePoint 2007 on the remote server
for file storage.
--
Here is a precise description of the problem.... any URL's have been
sanitized for public reading -
The routine which is enclosed is an Access 2007 routine that launches Word
2007 from within Access Visual Basic.
· It creates a late binding instance of MS Word 2007 from MS ACCESS
2007.
· When the program begins it tries to use GetObject(,"word.Application)
to see if there is an existing instance of word to use.
· If an error occurs, it then uses CreateObject ("word.application")
to launch word. Here is the relevant code:
Set wordobj = GetObject(, "word.application")
If Err.number <> 0 Then
'An error is thrown if word is not running
' So use create object to start word
Set wordobj = CreateObject("word.application")
MsgBox "CreateObject was used"
End If
wordobj.Documents.Add _
Template:="https://sharepoint.xyz.com/ClientInvoices/Invoice-Template/Invoice-Template.dotx",
Newtemplate:=False, Visible:=True
wordobj.Visible = True
· A template is populated with a series of bookmarks based on some
fields from an access data base. This is rather simple and works fine.
· Finally the file is saved using the following two commands. The
first line simply creates a file name. The second line does the save.
filename = "https://sharepoint.xyz.com/ClientInvoices/Invoices/" &
Me.txtNewInvoiceNumber & "-" & Me.txtProject & "-" & Format(Now(),
"mm-dd-yyyy-hh-mm") & ".doc"
ActiveDocument.SaveAs filename:=filename, FileFormat:=wdFormatDocument97
· THIS WORKS PERFECTLY SO LONG AS I DON"T CLOSE WORD.
It will save files over and over per the logic it follows.
Let me repeat - I CAN RUN THIS CODE PERFECTLY A MILLION TIMES SO LONG AS I
DON'T CLOSE WORD.
· HOWEVER IF I ADD THE FOLLOWING COMMAND AT THE END OF THE MODULE
THE CODE FAILS to SAVE. AND I DON"T THINK IT IS THE CODE, BUT MS OFFICE.
wordobj.Quit
· By adding a quit command, MS word ends and must be restarted by
the code.
· If word closes - either through the user closing it or through
this command,
the new instance of WORD created the next time the code is run, -> fails to
Save the document.
· The WORD DOCUMENT file is successfully opened,
the DOCUMENT fields filled in and the word document is fine,
BUT IT WILL NOT SAVE. THE SAVE SUDDENLY FAILS. AND FAILS EVERY TIME.
o As I test it, I get the following system error after the save attempt:
"462 - The remote machine does not exist or is unavailable"
· This should not occur. Yet it does. It appears that when the
access code tries to reestablish the connection to the Word instance, but
it has issues that are not user issues. It executes the createobject and
launches word fine, fills in the document but FAILS the SAVE.
My question is simple - WHY??????? AND HOW DO I FIX THIS.