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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Line to open Word/Excel Docs

Status
Not open for further replies.

oim

Programmer
Dec 17, 2002
7
AU
Hi,

I'm not an advanced user but would like to ask this basic question.

I'm trying to create a button to open a word file and another to open an excel file direct from access.

'Help' suggests I use 'Runapp' for macro but I'm not sure what the command line should look like (help doesn't give an example). A suggested command line would be a great help.

Thanks.
 
oim

Use the wizard when you add the command button to the form.

It will create code similiar to ...
Code:
    Dim stAppName As String, stDB As String
    stAppName = "C:\Program Files\Microsoft Office2000\Office\Excel.EXE"
    stDB = "F:\db\desktop\MyExcelDoc.xls"
    Call Shell(stAppName & " " & stDB, 1)

I have tweaked this code to open a specific document.

Richard
 
oharab posted this faq faq705-1971, which can be dropped into a general module (in VBE - Insert | Module).

When called, it will open the file using the default application, and wouldn't need any altering of path to the application.

Call it with for instance something like this:

[tt]dim strFileName as String
strFileName = "c:\test\mydoc.doc"
fHandleFile strFileName, WIN_NORMAL[/tt]

Roy-Vidar
 
Thanks a lot. You have helped me heaps.
 
Hello Roy (or anyone else),

I'm not sure if you've used this or not, but I used the above procedure you recommended and all works fine except the excel file freezes and i cannot see any of the cells. Just the tool bar. In the area where the cells are is an image of whatever was on the screen before I ran the proc. It's like windows is not refreshing that part of the screen.

Any advice?

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Lonnie, have you tried the Application.FollowHyperlink method ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
No I haven't. I ended up doing it with an object model like so....


DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryExportExcellData", strPath, True

Dim oApp As Object
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True

With oApp
.WorkBooks.Open (strPath)
End With
On Error Resume Next
oApp.UserControl = True

I'll look into that. Thanks.

ProDev, MS Access Applications
Visit me at ==>
May God bless you beyond your imagination!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top