Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

How to Open another application from MS Access

Status
Not open for further replies.

yousef20

Programmer
Jul 24, 2004
9
SA
good after noon

could any one help me, i'm tring to open another ms applications (word document) without closing my current application but i couldn't the following code only open an executable applications so can any one provide me with a code i'm searching for


Private Sub Command48_Click()
On Error GoTo Err_Command48_Click

Dim stAppName As String

stAppName = "D:\Documents and Settings\mubaya0e\My Documents\song.exe"
Call Shell(stAppName, 1)

Exit_Command48_Click:
Exit Sub

Err_Command48_Click:
MsgBox Err.Description
Resume Exit_Command48_Click

End Sub


thanks
 
I'm confused. You said you want to open a word document from your code, but the code you displayed is code to open an executable object. Not sure what you want, but if you're trying to open a word document, use this:

1) From your code window, select Tools > References. Make sure Microsoft Word x.x Object Library is checked.

2) Use the following code:
[tt]
Private Sub Command48_Click()
On Error GoTo Err_Command48_Click

Dim wordApp As Word.Application
Dim doc As Document
Dim stAppName As String

stAppName = "C:\DocumentName.doc"

Set wordApp = New Word.Application
wordApp.Visible = True
Set doc = wordApp.Documents.Open(stAppName)

'do stuff here...

Exit_Command48_Click:
Exit Sub

Err_Command48_Click:
MsgBox Err.Description
Resume Exit_Command48_Click

End Sub

[/tt]

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
Sorry about make you confuse, what i'm looking for is a general code to open any application for example a word documents
 
Take a look at this wrapper for the ShellExecute API Start an app with ShellExecute. Paste the code into a standard module (not forms/reports module), and call it like it's described in the samples within the code.

In cLFlaVA's sample, you have programattic control over the other application, this is an equivalence of doubleclicking a file in explorer to open an app with the selected document/file.

Roy-Vidar
 
thank you very much RoyVidar, the code you provide me is realy intersting and more than what i'm searching for

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top