• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

Calling a program?

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?
  • 3
  • 3
  • 3
  • +1
1 Solution
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.
Here is a link that might help you. It uses 2 API's There one of which is a new one for win2k. apiFindWindow.

Glen RichmondCustomer Reporting Programmer.Commented:
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
("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
good luck
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Glen RichmondCustomer Reporting Programmer.Commented:
also you can expose the functionality of any ole application using its object model. check your references and ocx controls to see whats avalible.
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

Open Word outside:
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
    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.
hirschhouseAuthor Commented:
Adjusted points from 100 to 110
hirschhouseAuthor Commented:
Outstanding, that's what i was looking for!
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
hirschhouseAuthor Commented:
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.


Glen RichmondCustomer Reporting Programmer.Commented:
yeh cheers for that i think Marine said it all.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 3
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now