Solved

Calling a program?

Posted on 2000-04-17
10
173 Views
Last Modified: 2010-05-02
How do i call another application from my VB6.0 program? example: i want to open an application like MS Word.

How do i make that same app a part of my VB program?

so, if i have a form with two buttons i want the first to open an app (word in this case) located at c:\program files\office\winword.exe. button 2 should be able to open the same app from within the program(not calling a UNC).

Can you help me?
Ben...
0
Comment
Question by:hirschhouse
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 6

Expert Comment

by:Marine
Comment Utility
I am going to get beat up now here.:). One you can use Shell() place a path of the word. Another is to use ShellExecute API function.
0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
Here is a link that might help you. It uses 2 API's There one of which is a new one for win2k. apiFindWindow.

http://support.microsoft.com/support/kb/articles/Q238/2/45.ASP
0
 
LVL 2

Expert Comment

by:Glen Richmond
Comment Utility
why use shell? Use the office reference to allow you to expose all the functionality of word thorough the object model ie.
 
dim wrd As Word.Application
wrd.Application.Visible = True
wrd.Documents.Open
("FileNameAsString"), , True
 
using the object variable method you can do anything in code you could do if using word itself.

check out the properties and method avalible.

if you need more help mail me
glenrichmond@hotmail.com
good luck
0
 
LVL 2

Expert Comment

by:Glen Richmond
Comment Utility
also you can expose the functionality of any ole application using its object model. check your references and ocx controls to see whats avalible.
0
 

Accepted Solution

by:
tdtomlins earned 110 total points
Comment Utility
This should be more than worth the points :-)).

When you say Same app within the program do you mean onto your VB Form?

And is it Word your trying to use?  If yes to both then the solution is yours

you can use the Shell to start a program
example of shell:

Dim strlong As Long
strlong = Shell("c:\test\testexe.exe", vbNormalFocus)

Second example of opening a File (word specifically
' you can use the below code referencing what ever program your using but this way allows you to insert text as well

'Make references to Microsoft Word 8 Object Libarary

1st:
Open Word outside:
Declariations:
Dim mobjWord As Word.Application
'Under a command Button
Dim strText As String
  strText = "This text was passed to the " _
    & "Microsoft Word ActiveX Server."
     
    Dim objDoc As Object
    Set mobjWord = New Word.Application
    mobjWord.Documents.Add
    Set objDoc = mobjWord.ActiveDocument
    objDoc.Range.InsertBefore strText
    mobjWord.Visible = True

'Closing out Word
On Error Resume Next
   mobjWord.Quit False
   Set mobjWord = Nothing

2nd opening onto your program:

USE the OLE container Control on your tools to import word into your document if you have troubles with this try help MSDN.MICROSOFT.COM goto search.

I can also get you a sample program of an OLE as well if you have troubles.

This should do you well.
Tom T.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:hirschhouse
Comment Utility
Adjusted points from 100 to 110
0
 

Author Comment

by:hirschhouse
Comment Utility
Outstanding, that's what i was looking for!
0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
thats actually what the other person and i talked about. I gave one solution the other gave another this one just put it together. Where is the fare game ? I think points were supposed to go to the other person who commented
0
 

Author Comment

by:hirschhouse
Comment Utility
He gave me the code i needed to drop right in to my project. yes you both did a great job, but the code didn't work 'till i saw tdtomlins ex.

Thank you all for your info, it helps me alot and i look forward to more help.

Thank you all once again.


Ben...

0
 
LVL 2

Expert Comment

by:Glen Richmond
Comment Utility
yeh cheers for that i think Marine said it all.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now