Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Shell or shellexecute

Hi,

I want to open A.dwg and B.dwg files in different moment from VBA
excel using Shell.
I use the following line and it works right:
RetVal = Shell(GstrPercorsoCad + " " + GstrFileAorB, vbMaximizedFocus)

The point is that I want to use only one process of Autocad because in
this way the program launchs two different execution of autocad.
what can i do to open the second file in the same apllication of the
first one?
Thanks.

IL
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Shell or shellexecute

First, I don't use Autocad.

But I thought that Autocad include VBA.

If that's the case, maybe you could use something like this that I use for
MSWord:

Option Explicit
Sub testme01()

Dim oWord As Object
Dim myWordTemplate As String
Dim testStr As String

myWordTemplate = "c:\msoffice\templates\1033\Elegant Fax.dot"

testStr = ""
On Error Resume Next
testStr = Dir(myWordTemplate)
On Error GoTo 0
If testStr = "" Then
MsgBox myWordTemplate & " doesn't exist"
Exit Sub
End If

On Error Resume Next
Set oWord = GetObject(, "Word.Application")
If Err Then
Set oWord = CreateObject("Word.Application")
End If

oWord.Visible = True
oWord.Documents.Add Template:=myWordTemplate

End Sub

The GetObject() stuff looks for an existing instance. If it's not found, then a
new instance is created.

The bad news is that you'll have to find out if this actually can work!

Hey!!!
From the first hit of a google search for: Automating Autocad
http://www.informit.com/articles/art...29033&seqNum=2

These two lines:
Dim A2K As AcadApplication
Dim A2Kdwg As AcadDocument
Depend on a reference (tools|References) in the excel's workbook project being
turned on.

Maybe you could use:
Dim A2K As Object
Dim A2Kdwg As Object

Riva Mario wrote:

Hi,

I want to open A.dwg and B.dwg files in different moment from VBA
excel using Shell.
I use the following line and it works right:
RetVal = Shell(GstrPercorsoCad + " " + GstrFileAorB, vbMaximizedFocus)

The point is that I want to use only one process of Autocad because in
this way the program launchs two different execution of autocad.
what can i do to open the second file in the same apllication of the
first one?
Thanks.

IL


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing a program which was opened with shellexecute JonT Excel Programming 1 February 27th 08 12:46 PM
Alternative to ShellExecute [email protected] Excel Programming 1 January 28th 08 09:35 PM
Open a file in the same instance with ShellExecute MichDenis Excel Programming 2 April 10th 07 04:16 AM
Shell Doesn't Work With UNC - Can't Get ShellExecute to Work Either [email protected] Excel Programming 1 September 1st 06 05:35 AM
Shellexecute fails with Excel rapple Excel Programming 0 June 24th 06 04:11 PM


All times are GMT +1. The time now is 02:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"