View Full Version : excel and autocad 2004
Hello, i'm a complete newbie in the area, although i've donne some vb programs.
I'm referencing a excel sheet with a file but, as much absurd as it sees. i just can't start excel. I'm always getting error.
This is my code:
Public Sub StartExcel(App As Excel.Application, Visible As Boolean)
On Error Resume Next
Set App = GetObject(, "Excel.Application.10")
If Err Then
Err.Clear
Set App = CreateObject("Excel.Application.10")
If Err Then
Exit Sub
End If
End If
App.Visible = Visible
End Sub
Public Sub Start()
Dim oExcel As Excel.Application
'attempt to start Excel
StartExcel oExcel, True
If Not oExcel Is Nothing Then
MsgBox "Success"
Else
MsgBox "Could not start Excel, exiting ...", vbCritical
Exit Sub
End If
End Sub
i mean more simple then this can't be. i've added the reference:
microsoft Excel 10.0 object library
What the heck could be wrong?
Thanks in advance
hsa
TCARPENTER
12-04-2005, 02:35 PM
Hi hsa,
You didn't mention what exactly the error was but I do notice you'll need to change your Visible variable to something else like blnVisible and see if that fixes your problem, if not post back with the error message you're receiving.
HTH
Todd
Hello TCARPENTER,
thanks for you're reply.
Here's the error i got:
"Run time error '429'
ActiveX component can't create object"
This why i just can't understand whats wrong. If i have it referenced, why do i get this?
Thanks again
hsa
TCARPENTER
12-04-2005, 05:08 PM
Hi hsa,
Try this approach and see if you still have trouble:
Public oExcel As Excel.Application
Public Sub StartExcel(blnVisible As Boolean)
On Error Resume Next
Set oExcel = GetObject(, "Excel.Application.10")
If Err Then
Err.Clear
Set oExcel = CreateObject("Excel.Application")
If Err Then
Exit Sub
End If
End If
oExcel.Visible = blnVisible
End Sub
Public Sub Start()
'attempt to start Excel
StartExcel True
If Not oExcel Is Nothing Then
MsgBox "Success"
Else
MsgBox "Could not start Excel, exiting ...", vbCritical
Exit Sub
End If
End Sub
HTH
Todd
Good morning TCarpenter,
Thanks again for the reply. I'm affraid i'm still gettin the same error with you're solution. I'm just puzzled with this. There shouldn't be any reason for this error.
TCARPENTER
15-04-2005, 12:02 AM
Hi hsa,
Sorry to get back to you so late...
This one has me stumped too. How is your system setup OS, Office Version, service packs etc.
What all do you have referenced in your project?
Can you connect to Excel if it is already running?
Let me know.
Todd
so sorry for the late reply. Problems with my isp.
Ok here's the specks:
XP pro sp2, Office XP Pro sp3 (thats why i have the Excel aplication.10 ), but this also happen with Office xp Pro sp2.
And no, with or without Excel running I get the same error.
Thanks again for the reply and for the help.
regards
TCARPENTER
20-04-2005, 10:59 AM
Hi hsa,
I have to admit that at this point I'm suspicious of a bad install and/or that it may be time to rebuild the machine. If you are still getting the same error with Excel running, "ActiveX can't create object", try changing this line:
Set oExcel = GetObject(, "Excel.Application.10")
To:
Set oExcel = GetObject(, "Excel.Application")
Before you throw in the towel though, try connecting to Excel from Word, Access or any other office VBA application and see if you are successful. If you are, it may be an AutoCAD problem. If your code is VB, it may be a VB problem.
HTH
Todd
ok, i may trow the towel :) since already did that before coming to here.
as for the word, i get the same problem.
Never the less thabks for all you're help.
I'll try to upgrade autocad before going to the clean install.
I'll be back with more news after doing this.
regards
hsa
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.