opening powerpoint and word from excel

H

hebe

I created a button to open a folder on our network. I can
open the excel files but the Powerpoint Word and Access
files I can't can anyone help me? I am also trying to
open adobe acrobat files with excel any help
thanks
 
L

Laurent van Roy

hebe said:
I created a button to open a folder on our network. I can
open the excel files but the Powerpoint Word and Access
files I can't can anyone help me? I am also trying to
open adobe acrobat files with excel any help
thanks

Just use the standard windows functions.

Private Declare Function ShellExec Lib "shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long


Private Sub OpenMyFile(myFile As String)
Dim nResult
nResult = ShellExec(0, "open", myFile, "", "", 1)

If (nResult <> 33) Then MsgBox "Error !"
End sub


This will do the same thing that if you were double-clicking on the
"MyFile" item in window.
I have tested it with a folder, and it opens a window. It should work
with evry other file.

Laurent
 
G

Guest

I tried using this code in the button i made in excel but
kept getting an error message can you give me an ideal of
what I am doing wrong. this is the code i use to open the
directory

On Error GoTo ErrTrap

ChDir "c:\directory"

fileToOpen = Application.GetOpenFilename("excel Files
(*.xls), *.xls")
Workbooks.Open (fileToOpen)
Exit Sub

ErrTrap:
If Err.Number = 1004 Then
Exit Sub
Else
MsgBox Err.Description
Exit Sub
End If
End Sub
 
L

Laurent van Roy

I tried using this code in the button i made in excel but
kept getting an error message can you give me an ideal of
what I am doing wrong. this is the code i use to open the
directory
Which error do you get ?

Can I suggest you to write proper code, with variable declaration and
an "Option Explicit" statement:


Option Explicit

Sub OpenFile ()
Dim fileToOpen as Variant

On Error GoTo ErrTrap

ChDir "c:\directory"

fileToOpen = Application.GetOpenFilename("excel Files (*.xls),
*.xls")

if (fileToOpen <> False) then _
Workbooks.Open (fileToOpen)
Exit Sub

ErrTrap:
If Err.Number = 1004 Then
Exit Sub
Else
MsgBox Err.Description
Exit Sub
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top