Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

Got a question and need support on Active X error message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brent E - 15 Mar 2005 18:05 GMT
Good morning,

I am using an Access 2003 on an XP Pro computer and using an Access module
and an object variable to control Excel and things seem to function w/ no
problems if Excel is open, but if Excel is closed, my code should test to see
if Excel is already open, if not module should launch Excel. This is my code

 Dim OBJ As Object
    On Error Resume Next
    Set OBJ = GetObject(, "EXCEL.Application")
    If ERR.Number <> 0 Then
       ERR.Clear
       Set OBJ = CreateObject("EXCEL.APPLICATION")
    Else: MsgBox ERR.Description
    End If
But I get an error saying "Runtime error 429, Active X component can't
create object." I went to microsoft webiste and looked up the error and
explanation is that "You tried to place an Active X control on a form at
design time or add a form to a project with an Active X control, but the
associated information in the registry could not be found."...."to correct
the problem, the information in the registry may have been deleeted or
corrupted. Reinstall the Active X control or contact the control vendor."
Problem is I don't recall every changing, installing, or messing w/ any
Active X controls. I also have included in my module's references "Microsoft
Active X Data Objects 2.1 Library " and "Microsoft ActiveX Data Objects
Multidimensional 2.7 Library". I am curious, do these at all conflict w/ each
other, must I encorporate a different Active X library, do I need to
reinstall Access, or do I need a service pack update? I am not sure how to
correct this problem. Any suggestions? Thanks. Cordially,
Ken Snell [MVP] - 15 Mar 2005 19:01 GMT
The code you posted is exactly what you are using? Change it to this:

 Dim OBJ As Object
    On Error Resume Next
    Set OBJ = GetObject(, "EXCEL.Application")
    If ERR.Number <> 0 Then
       ERR.Clear
       Set OBJ = CreateObject("EXCEL.APPLICATION")
    End If

You don't need the "Else: MsgBox..." step when there is no error.

Signature

       Ken Snell
<MS ACCESS MVP>

> Good morning,
>
[quoted text clipped - 29 lines]
> reinstall Access, or do I need a service pack update? I am not sure how to
> correct this problem. Any suggestions? Thanks. Cordially,
Brent E - 15 Mar 2005 20:43 GMT
Thanks. Actually I tried remming out the line and also deleting the line, but
I still get same error. Seems to be something wrong w/ my Active X control in
registry or something. Any ideas? Thanks.

> The code you posted is exactly what you are using? Change it to this:
>
[quoted text clipped - 41 lines]
> > reinstall Access, or do I need a service pack update? I am not sure how to
> > correct this problem. Any suggestions? Thanks. Cordially,
Ken Snell [MVP] - 15 Mar 2005 20:53 GMT
On which code line do you get the error? When the error message box shows
up, click "Debug" button and see which line is highlighted in yellow.

Signature

       Ken Snell
<MS ACCESS MVP>

> Thanks. Actually I tried remming out the line and also deleting the line,
> but
[quoted text clipped - 56 lines]
>> > to
>> > correct this problem. Any suggestions? Thanks. Cordially,
Brent E - 15 Mar 2005 23:49 GMT
I found that when I click on Debug, the error occurs in line:
   Set OBJ = GetObject(, "EXCEL.Application")
but as far as I know there isn't anything wrong w/ this line, and it works
just fine if Excel is open. Only errors when Excel is closed. What do u think
about this? Thanks.


> On which code line do you get the error? When the error message box shows
> up, click "Debug" button and see which line is highlighted in yellow.
[quoted text clipped - 59 lines]
> >> > to
> >> > correct this problem. Any suggestions? Thanks. Cordially,
Ken Snell [MVP] - 16 Mar 2005 02:16 GMT
That line should error when EXCEL is not open. That is the reason for the
   On Error Resume Next
line in the code -- the code should not break and should instead continue to
the next code line.

Thus, I'm thinking that you need to change a setting in Visual Basic Editor.
Open VBE, and click Tools | Options | General tab. Be sure that the option
for "Break on Unhandled Errors" is the option that is set on the right side
of the window.

Signature

       Ken Snell
<MS ACCESS MVP>

>I found that when I click on Debug, the error occurs in line:
>    Set OBJ = GetObject(, "EXCEL.Application")
[quoted text clipped - 79 lines]
>> >> > to
>> >> > correct this problem. Any suggestions? Thanks. Cordially,
Dave Patrick - 16 Mar 2005 02:46 GMT
Something like this may also work.

set list = getobject("winmgmts:").execquery(_
 "select * from win32_process where name='excel.exe'")
If list.count > 0 Then
   msgbox "excel is running"
Else
   msgbox "excel is not running"
End If

Signature

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

|I found that when I click on Debug, the error occurs in line:
|    Set OBJ = GetObject(, "EXCEL.Application")
| but as far as I know there isn't anything wrong w/ this line, and it works
| just fine if Excel is open. Only errors when Excel is closed. What do u think
| about this? Thanks.
Brent E - 16 Mar 2005 18:41 GMT
Good morning guys. Thanks. I just got your messages. I appreciate u guys
helpin me out on this. Ken, I checked my setting as u suggested. Yes, my
settings were set to stop on all errors, I changed that to only on unhandled
errors and no I do not get an error, but if Excel is closed, Excel does not
seem to open even w/ the following additions to my code. I thought maybe
Excel was opening in background and I just couldn't see it, but when I went
into task manager and looked at applications and processes running, there are
no representations of Excel that I can see. What do u suggest? Thanks

And Dave, thanks for that terrific code suggestion. If I can't get sub I
already got going to work, I will definitely give that a try. I didn't know u
could use a win32 process like that. Very cool. What are the winmgmts and
execquery processes. I've not known I could use those before and would like
to know more about those. Thanks again.

> Something like this may also work.
>
[quoted text clipped - 12 lines]
> think
> | about this? Thanks.
Dave Patrick - 16 Mar 2005 18:51 GMT
A couple of links to get you started.

http://www.microsoft.com/technet/scriptcenter/default.mspx
http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx

Signature

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

| Good morning guys. Thanks. I just got your messages. I appreciate u guys
| helpin me out on this. Ken, I checked my setting as u suggested. Yes, my
[quoted text clipped - 10 lines]
| execquery processes. I've not known I could use those before and would like
| to know more about those. Thanks again.
Brent E - 16 Mar 2005 18:47 GMT
I forgot to insert my code into my last post. These are updates to my code:
 Dim OBJ As Object
    On Error Resume Next
    Set OBJ = GetObject(, "EXCEL.Application")
    If ERR.Number <> 0 Then
       ERR.Clear
       Set OBJ = CreateObject("EXCEL.APPLICATION")
    End If
    OBJ.Visible True
    OBJ.Workbooks.Add
But I still do not see Excel open or open a workbook.

> Something like this may also work.
>
[quoted text clipped - 12 lines]
> think
> | about this? Thanks.
Ken Snell [MVP] - 16 Mar 2005 19:11 GMT
Code looks fine. So let's see what might be happening. Insert a step to put
up a msgbox with error number and description after CreateObject...let's see
if there is a problem there for some reason.

 Dim OBJ As Object
    On Error Resume Next
    Set OBJ = GetObject(, "EXCEL.Application")
    If ERR.Number <> 0 Then
       ERR.Clear
       Set OBJ = CreateObject("EXCEL.APPLICATION")
       MsgBox "error " & err.number & " : " & err.description
    End If
    OBJ.Visible True
    OBJ.Workbooks.Add

Signature

       Ken Snell
<MS ACCESS MVP>

>I forgot to insert my code into my last post. These are updates to my code:
>  Dim OBJ As Object
[quoted text clipped - 25 lines]
>> think
>> | about this? Thanks.
Dave Patrick - 16 Mar 2005 19:13 GMT
Try something like this.

   Dim OBJ As Object, list As Object
   Set list = GetObject("winmgmts:").execquery("select " _
       & "* from win32_process where name='excel.exe'")
   If list.Count > 0 Then
       MsgBox "excel is running"
   Else
       MsgBox "excel is not running"
       Set OBJ = CreateObject("EXCEL.APPLICATION")
       OBJ.Workbooks.Add
       OBJ.Application.Visible = True
End If

Signature

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

|I forgot to insert my code into my last post. These are updates to my code:
|  Dim OBJ As Object
[quoted text clipped - 7 lines]
|     OBJ.Workbooks.Add
| But I still do not see Excel open or open a workbook.
Steven M. Britton - 16 Mar 2005 22:37 GMT
This is what I use and have never had a problem...

Function SendtoExcel()

Dim xlsApp As Object
Dim wkb As Object
Dim strPath As String
Dim wkbTemp As Object
Dim wks As Object
On Error Resume Next
   Set xlsApp = GetObject("Excel.application")
If Err Then
   Set xlsApp = CreateObject("Excel.Application")
End If
xlsApp.Activate
xlsApp.Visible = False
strPath = "C:\file\temp.xls"
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query", strPath
DoCmd.SetWarnings True
Set wkbTemp = xlsApp.Workbooks.Open(strPath)

xlsApp.Visible = True

End Function

> Try something like this.
>
[quoted text clipped - 21 lines]
> |     OBJ.Workbooks.Add
> | But I still do not see Excel open or open a workbook.
Brent E - 17 Mar 2005 02:09 GMT
Terrific. Thanks guys. I am sorry I didn't respond sooner, I got called away
to another office to assist w/ a program. I will give all of your suggestions
a try and keep u posted tomorrow. Thanks again guys, have a terrific evening.

> This is what I use and have never had a problem...
>
[quoted text clipped - 47 lines]
> > |     OBJ.Workbooks.Add
> > | But I still do not see Excel open or open a workbook.
Brent E - 17 Mar 2005 19:09 GMT
Good morning guys, I looked at everybody's suggestions and was able to get
the procedure to work. I assume I would use similar code to test to see if
Word is open and if not to run Word also? Thanks for all your terrific
assistance. I really appreciate your time.

> This is what I use and have never had a problem...
>
[quoted text clipped - 47 lines]
> > |     OBJ.Workbooks.Add
> > | But I still do not see Excel open or open a workbook.
Ken Snell [MVP] - 17 Mar 2005 19:49 GMT
Yes.

Signature

       Ken Snell
<MS ACCESS MVP>

> Good morning guys, I looked at everybody's suggestions and was able to get
> the procedure to work. I assume I would use similar code to test to see if
[quoted text clipped - 54 lines]
>> > |     OBJ.Workbooks.Add
>> > | But I still do not see Excel open or open a workbook.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.