Hi everyone?
I'm trying to open a excel file trough autocad VBA.
my question is: can i open a excel file the same way as VB6?, or i will have to use some API, because i can´t make a reference to excel object library in the autocad VBA.
Thanks.
Printable View
Hi everyone?
I'm trying to open a excel file trough autocad VBA.
my question is: can i open a excel file the same way as VB6?, or i will have to use some API, because i can´t make a reference to excel object library in the autocad VBA.
Thanks.
This may not be the best way, but I have no idea how AutoCad VBA works.
But, if you can run an API in it, I would use ShellExecute to open your spreadsheet.
Thread Moved
Why would you need to make a reference to Excel if you just want to open the workbook? Unless you are also doing some automation then you can solve that with using Late Binding.
ShellExecute API example:
Late Binding:Code:Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2
Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", "C:\Users\Public\Book1.xls", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
http://www.vbforums.com/showthread.php?t=406640
Thanks a lot RobDog888 and Hack!
But i have one more question, how can i put values into a excel sheet cells trough VBA in the opened excel document?
The idea here is to open and write to a template excel file information from a autocad drawing.
By the way robdog what you mean by Late Binding?
Please if you know some thread or tutorial to manipulate excel trough VBA, please post it Thanks.
see the office development faq link in robdog post above