I have an access database working in a mixed environment (some 2010, now a couple 2013). The 2010 databases work fine. Basically, I'm trying to open a word document from access, an existing one. Here's the code I have:
Private Sub CreateQuote_Click()
On Error Resume Next
Dim filePath As String
Dim rst As Recordset
Dim strSQL As String
Dim rng As Object
Dim Quote As Variant
Dim objword As Word.Application
strSQL = "Select QuotesBaseDir from tblsystem"
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset, dbPessimistic)
Set objword = New Word.Application
'objword.Documents.Add
objword.Documents.Open "F:\Data\Word\" & Environ("USERNAME") & "\USA Coil Master.doc"
filePath = rst!QuotesBasedir & Int(Me.QuoteIDPK / 1000) & ".xxx\"
The QuotesBaseDir from tblSystem is the file path to the quote documents. To create a new quote, I need to open an existing word document in the location shown (F:\Data\Word etc). However when the code gets to this line:
Set objword = New Word.Application
The macro hangs for a very long time. When I press Ctrl+Break I get the following message:
All I want to do is open the word document in the directory specified.
Any help is appreciated.
Need to open a word doc from access 2013
-
- 3StarLounger
- Posts: 235
- Joined: 08 Jun 2010, 20:03
- Location: Morgantown, PA
Need to open a word doc from access 2013
Cordially,
Bob Sullivan
Elverson, PA
Bob Sullivan
Elverson, PA
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Need to open a word doc from access 2013
Hi Bob,
Try these lines:
Please note...this is not my field of expertise
I managed to find a fairly good reference to opening and using Word documents in Access. For MUCH more detail and control see this web page.
Try these lines:
Code: Select all
Dim objWord as Object
Dim doc as Object
Set objWord = CreateObject("Word.Application")
Set doc = objWord.Documents.Open("F:\Data\Word\" & Environ("USERNAME") & "\USA Coil Master.doc")
ObjWord.Visible = True
I managed to find a fairly good reference to opening and using Word documents in Access. For MUCH more detail and control see this web page.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 3StarLounger
- Posts: 235
- Joined: 08 Jun 2010, 20:03
- Location: Morgantown, PA
Re: Need to open a word doc from access 2013
Nope. Still hangs terribly on:
Set objWord = CreateObject("Word.Application")
before giving the error message error 429, ActiveX component can't create object.
Actually, this error comes up in the original code if I wait long enough.
Set objWord = CreateObject("Word.Application")
before giving the error message error 429, ActiveX component can't create object.
Actually, this error comes up in the original code if I wait long enough.
Cordially,
Bob Sullivan
Elverson, PA
Bob Sullivan
Elverson, PA
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Need to open a word doc from access 2013
Try this advice to help resolve the error...
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 3StarLounger
- Posts: 235
- Joined: 08 Jun 2010, 20:03
- Location: Morgantown, PA
Re: Need to open a word doc from access 2013
I appreciate the links to the files, but none of these solutions apply. The problem is that when I copy this database and run this code on an Access 2010 it works perfectly. When I copy this database and run this code on an Access 2013 machine, it gives me the ActiveX error. It's not a bug in the system, it's a situation that only appears in Access 2013. And we are running separate copies of the database.
Cordially,
Bob Sullivan
Elverson, PA
Bob Sullivan
Elverson, PA
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: Need to open a word doc from access 2013
Does it help if you change
Dim objword As Word.Application
to
Dim objword As Object
Dim objword As Word.Application
to
Dim objword As Object
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Need to open a word doc from access 2013
Hi Bob,
I'm just shooting in the dark and throwing out some options. Hopefully one might work to resolve...
BTW: I ran the both versions of the code in a sample database I set up and both versions open the Word document I pointed to, albeit that the version I posted,
opened it a tad faster than the version you used,
So, the problem is NOT in the code (as you say), but probably in the environment.
Can I ask what bit version of Office (Access) 2013 is installed on the PC('s) causing the error? I read an article informing that some ActiveX controls are different between 32bit installations and 64bit installations. If the PC's running Office 2013 are 64bit, then that might be the source of the error. See here!
If none of the above is the source of the error...and out of desperation , see if anything here can help. Its another Microsoft Support page that goes deeper into other troubleshooting steps on the particular error...
ADDITION:
By weird coincidence, while testing something else I mis-spelt the word Application and it produced the exact error in question.... Just humour me and check if there is not possible a mis-spelling in your code
I'm just shooting in the dark and throwing out some options. Hopefully one might work to resolve...
BTW: I ran the both versions of the code in a sample database I set up and both versions open the Word document I pointed to, albeit that the version I posted,
Code: Select all
Set objWord = CreateObject("Word.Application")
Code: Select all
Set objword = New Word.Application
Can I ask what bit version of Office (Access) 2013 is installed on the PC('s) causing the error? I read an article informing that some ActiveX controls are different between 32bit installations and 64bit installations. If the PC's running Office 2013 are 64bit, then that might be the source of the error. See here!
If none of the above is the source of the error...and out of desperation , see if anything here can help. Its another Microsoft Support page that goes deeper into other troubleshooting steps on the particular error...
ADDITION:
By weird coincidence, while testing something else I mis-spelt the word Application and it produced the exact error in question.... Just humour me and check if there is not possible a mis-spelling in your code
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 3StarLounger
- Posts: 235
- Joined: 08 Jun 2010, 20:03
- Location: Morgantown, PA
Re: Need to open a word doc from access 2013
I believe I have found the fix, but I cannot test it on the actual machine as of yet. I was able to duplicate the error and then fix it on another 2013 machine.
The Microsoft Word 15.0 Object Library needs to be checked on the 2013 machines. In the visual basic screen, it's under Tools, References.
I would really like it if Microsoft would create a list or a chart that basically explains which references need to be turned on or off for different things.
The Microsoft Word 15.0 Object Library needs to be checked on the 2013 machines. In the visual basic screen, it's under Tools, References.
I would really like it if Microsoft would create a list or a chart that basically explains which references need to be turned on or off for different things.
Cordially,
Bob Sullivan
Elverson, PA
Bob Sullivan
Elverson, PA
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Need to open a word doc from access 2013
That's great to hear. I trust it will resolve on the other PC's too.
Cheers Bob
Cheers Bob
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.