iceli
01-18-2008, 07:53 AM
I am tring to get ms access 2003 to start or open up some of microsoft applications depending on the file type and path that is present in a text field. The following code will open the word application but I want to also open up an excel application if it was the file present in the text field...even a pdf doc.
[code]
Sub OpenWordDoc(strDocName As String)
Dim objApp As Object
Set objApp = CreateObject("Word.Application")
objApp.Visible = True
objApp.Documents.Open strDocName
End Sub
DCrake
02-22-2008, 04:12 AM
Ok
Have a form that lists the potiential fiels you want to open - using dir/file list box components.
Next in the General Declarations of the form
place the following code
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Private Declare Function GetDesktopWindow Lib "User32" () As Long
Const SW_SHOWNORMAL = 1
Dim sPath As String
Finally on the double-click event of the control place the following
sPath = "C:\TempANS\"
strFile = sPath & Me.List1
nDT = GetDesktopWindow()
nApp = ShellExecute(nDT, "Open", strFile, "", "C:\", SW_SHOWNORMAL)
DoEvents
This will open any type of file without trying to determine the type of file the user has selected.
CodeMaster::cool:http://www.icraftlimited.co.uk
iceli
02-22-2008, 05:23 AM
Ok
Have a form that lists the potiential fiels you want to open - using dir/file list box components.
Next in the General Declarations of the form
place the following code
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Private Declare Function GetDesktopWindow Lib "User32" () As Long
Const SW_SHOWNORMAL = 1
Dim sPath As String
Finally on the double-click event of the control place the following
sPath = "C:\TempANS\"
strFile = sPath & Me.List1
nDT = GetDesktopWindow()
nApp = ShellExecute(nDT, "Open", strFile, "", "C:\", SW_SHOWNORMAL)
DoEvents
This will open any type of file without trying to determine the type of file the user has selected.
CodeMaster::cool:http://www.icraftlimited.co.uk
hello DCrake...thank u for ur response but iv found a piece of code that does the trick well.however il try ur code as soon as i can...thanks again.