Using the ShellExecute API to open any version of AutoCAD??
Hi there,
Does anyone have any sample Code of how to use ShellExcute to open an executable?
I need to be able to open any version of AutoCAD from my VB application and
I believe ShellExecute is the way to go.
Any help would be appreciated.
Regards,
Rebecca
[300 byte] By [
Beck] at [2007-11-10 0:20:20]

# 1 Re: Using the ShellExecute API to open any version of AutoCAD??
On a form w/ a command button paste:
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
Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "C:\Program Files\Microsoft
Office\Office\Samples\Samples.xls", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
...substitute a proper path for your CAD file...should give you the idea.
"Beck" <henihan@iol.ie> wrote in message news:38d3cb6b$1@news.dev-archive.com...
>
> Hi there,
>
> Does anyone have any sample Code of how to use ShellExcute to open an
executable?
>
> I need to be able to open any version of AutoCAD from my VB application
and
> I believe ShellExecute is the way to go.
>
> Any help would be appreciated.
>
> Regards,
> Rebecca
# 2 Re: Using the ShellExecute API to open any version of AutoCAD??
On a form w/ a command button paste:
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
Const SW_SHOWNORMAL = 1
Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "C:\Program Files\Microsoft
Office\Office\Samples\Samples.xls", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
...substitute a proper path for your CAD file...should give you the idea.
"Beck" <henihan@iol.ie> wrote in message news:38d3cb6b$1@news.dev-archive.com...
>
> Hi there,
>
> Does anyone have any sample Code of how to use ShellExcute to open an
executable?
>
> I need to be able to open any version of AutoCAD from my VB application
and
> I believe ShellExecute is the way to go.
>
> Any help would be appreciated.
>
> Regards,
> Rebecca
# 3 Re: Using the ShellExecute API to open any version of AutoCAD??
I believe ShellExecute() is used to launch a file (document) using its
registered program or editor.
I.e. you would open an autoCad file, not autocad itself.
AutoCad uses VBA doesn't it? Perhaps it is an automation server.
If you just want to launch autocad asynchronously (which is the best and
safest way), just use shell().
I expect autocad can specify command-line options such as the file(s) to
open.
Also, if AutoCad supports automation, passing the return of shell() to
getObect is one way to get an automation handle, among others.
Good luck.
Beck <henihan@iol.ie> wrote in message news:38d3cb6b$1@news.dev-archive.com...
>
> Hi there,
>
> Does anyone have any sample Code of how to use ShellExcute to open an
executable?
>
> I need to be able to open any version of AutoCAD from my VB application
and
> I believe ShellExecute is the way to go.
>
> Any help would be appreciated.
>
> Regards,
> Rebecca
# 4 Re: Using the ShellExecute API to open any version of AutoCAD??
I believe ShellExecute() is used to launch a file (document) using its
registered program or editor.
I.e. you would open an autoCad file, not autocad itself.
AutoCad uses VBA doesn't it? Perhaps it is an automation server.
If you just want to launch autocad asynchronously (which is the best and
safest way), just use shell().
I expect autocad can specify command-line options such as the file(s) to
open.
Also, if AutoCad supports automation, passing the return of shell() to
getObect is one way to get an automation handle, among others.
Good luck.
Beck <henihan@iol.ie> wrote in message news:38d3cb6b$1@news.dev-archive.com...
>
> Hi there,
>
> Does anyone have any sample Code of how to use ShellExcute to open an
executable?
>
> I need to be able to open any version of AutoCAD from my VB application
and
> I believe ShellExecute is the way to go.
>
> Any help would be appreciated.
>
> Regards,
> Rebecca