VB Command

J

Jasper Recto

I have a button that runs the function below. It opens an excel document.
I also have other funtion that opens up other documents whether it be a word
or pdf docuement.

This command opens each document in an explorer window.

How can I make a generic command that will open up the file in its native
program. That way an excel file will open in excel, etc...

Thanks,
Jasper



Function Administration()
Dim MyPath As String
Dim Word

MyPath = "\\LocFile\Departments\Quality
Control\Public\ISO-TS16949\ADMINISTRATION INDEX.xls\"
Word = Shell("Explorer.exe " & MyPath & """", 1)

End Function
 
B

Bernd Gilles

Hello Jasper,

Jasper said:
How can I make a generic command that will open up the file in its native
program. That way an excel file will open in excel, etc...

something like this?

Public Const WIN_NORMAL = 1 'Open Normal
Public Const WIN_MAX = 3 'Open Maximized
Public Const WIN_MIN = 2 'Open Minimized

Public Declare Function ShellExecute 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

Sub TestEx
TheFile = "C:\YourPath\YourFile.pdf"
ShellExecute(hWndAccessApp, vbNullString, TheFile, vbNullString, vbNullString, WIN_MAX)
End Sub
 
L

Léon Hajduk

Jasper Recto said:
I have a button that runs the function below. It opens an excel document.
I also have other funtion that opens up other documents whether it be a
word or pdf docuement.

This command opens each document in an explorer window.

How can I make a generic command that will open up the file in its native
program. That way an excel file will open in excel, etc...

Thanks,
Jasper



Function Administration()
Dim MyPath As String
Dim Word

MyPath = "\\LocFile\Departments\Quality
Control\Public\ISO-TS16949\ADMINISTRATION INDEX.xls\"
Word = Shell("Explorer.exe " & MyPath & """", 1)

End Function
 
E

eduardo freitas

Jasper Recto said:
I have a button that runs the function below. It opens an excel document.
I also have other funtion that opens up other documents whether it be a
word or pdf docuement.

This command opens each document in an explorer window.

How can I make a generic command that will open up the file in its native
program. That way an excel file will open in excel, etc...

Thanks,
Jasper



Function Administration()
Dim MyPath As String
Dim Word

MyPath = "\\LocFile\Departments\Quality
Control\Public\ISO-TS16949\ADMINISTRATION INDEX.xls\"
Word = Shell("Explorer.exe " & MyPath & """", 1)

End Function
 

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