Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launching Application via VB6 program 1

Status
Not open for further replies.

abbver98

Mechanical
Jun 21, 2002
195
If anyone knows how to launch an executable (.exe) by a VB6 progam and at the same time use its command .
For example : I want to write a VB program that open an Autocad application, do modifications and save the file opened. I had to use the autocad command in my VB6 program.
Thanks
 
Replies continue below

Recommended for you

Have you tried the shell command?

It will run an external program in a separate window. If you need to wait for the external program to finish first before you do something else it becomes more complex.
 
Shell can be used to start the programme, then you could set up a link between your VB programme and AutoCAD and use Dynamic Data Exchange to get VB to do something in AutoCAD.
 
Thanks to rush and PeterCharles.
I try the shell command, it works. But I don't know how to use Dynamic Data Exchange commands ! Where I can find those commands ?
My problem is that I want to open a list of autocad dwgs to do some modifications and to save them. I think I had to use few DDE commands. I'm not familiar with DDE commands. Any help or examples showing the use of such commands.
 
Any examples showing the use of DDE commands !
 
Why would you try to use DDE afterall ? In Autocad you could use VBA or access Autocad object model directly through your program by instantiating... surprise surprise Autocad :)

So there is no need to use shell or any other API method to start an Autocad, just reference the Autocad object and the Autocad engine starts.

You can control Autocad form your code directly.

Another way is to start an autocad with parameters to run predefined script, also you could make an Autocad VBA module an play with it - but best route to control Autocad is via Autocad object.




 
No I don't want to use Lisp or Autocad instructions, more complicated !
I have 200 dwg to convert. I work with I-DEAS artisan, and I don't do any effort to return to autocad.
I want to work with VB, think is easy !
 
The easiest way to start a program is to use the Internet Shortcut technique like this:
Put a Text1 and a button (Command1) on your form and add this code to Command1_Click:

Sub Command1_Click()
Dim sFile as string
Dim F as Integer

sFile = Text1.Text
F = FreeFile
Open "C:\TEMP.URL" For Output As #F
Print #F, "[InternetShortcut]"
Print #F, "URL=" & sFile
Close #F
Shell "rundll32.exe shdocvw.dll,OpenURL c:\temp.url", vbNormalFocus
end sub

This will create a file on C:\ called TEMP.URL which will be overwritten next time you click the button. Be sure to add something in the Text1 field like
 
Thank you very much Gaba . I star you !
It work good but I still need instruction for saving automatically. I want to save as Autocad 14.0 (the version used is 2000).
Awaiting for help
 
Read the FAQ for information on manipulating AUTOCAD using automation control from VB6
 
abbver98,
I was reading your posting and all I have to said is,

Please take a breath,,
and enjoy "Mastering AutoCAD VBA" by Marion Cottingham, you can take a trip to your library. They can get the book for you, and if you like, you could learn a few commnands in VBA, AND YOU CAN STILL WORKING IN VBA, and you can finish your project in two or three days.

The command shell, is not good enough.

And you can get the Commom Dialog in Visual Basic, and with ShowSave or ShowSaveAs, you can save all your records.

AND REMEMBER ALL IN VISUAL BASIC, combined with VBA.

Alberto
 
If you want to know something about Dynamic Data Exchange (DDE) check out
This was my first introduction to using VB to 'programme' AutoCAD LT and I have had some good results.

What you do is to set up a conversation (read the VB instructions on DDE) between the VB programme and AutoCAD. The programme then sends instructions to the command line of AutoCAD. The big advantage is being able to programme both versions of AutoCAD.

Initially I created a drawing in VB as a DXF which I then 'inserted' into an AutoCAD drawing, but this resulted in the drawing becoming a block, not quite what I wanted.

Am currently finishing a programme to 'draw' standard structural steel sections. When finished it will be able to be used by my guys with both 'very expensive' AutoCAD and 'less expensive' AutoCAD LT.

I haven't tried to use any of the file commands but I don't see why you can't but you may have to experiment.
 
Is this project done or are you still in need of help?
 
If I understand from the previous posts:
-SHELL will launch an .EXE but then continues (non-modal)
-EXECUTE (program I wrote) launches .EXE and waits till done

Your task more explicitly defined:
From a VB6 application:
-Launch ACAD r14
-Open a specific .DWG file
-Modify the DWG
-Save the modified .DWG
-Exit & Close ACAD r14 application

If this is the case;
what's the specifics of Modify
 
I don't know if this will help but to do everything at the command prompt you can use :-

FILEDIA (enter)
0 (enter)
SAVEAS (enter)
R14 (enter)
"filepath and name" (enter)

So, if you can pass these instructions to AutoCAD then the drawing will be saved as Release 14
 
I think U need to use a (Reference) to the *.exe U need..
and that is, U can use the functions of the program U need.. if this program is one of the Windows components ,U will need to have some readings about Win API.. To make a reference and use a program functions via VB,, go to the menu,, Project,, Reference and check the progam U need to use its functions.. check this program help,, some gives instructions and hints for the programmers about using its functionalities as REFERENCE.. sorry about my bad English,,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor