VB Command

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
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
 
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
 
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
 
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
 
Back
Top