M
MichDenis
Hi everyone,
If someone knows if it's possible to use "ShellExecute"
(not workbooks.open) to open a file in the same instance
of the application where the macro is ? If yes, How to do it ?
'API
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
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'-----------------------------------------
Sub ShellOpenFile()
Const SW_SHOWNORMAL = 1
Dim hwnd As Long
Dim File As String
File = "C:\Workbook2.xls"
hwnd = FindWindow(vbNullString, Application.Caption)
ShellExecute hwnd, "open", File, vbNullString, vbNullString, SW_SHOWDEFAULT
End Sub
'-----------------------------------------
Thanks for your collaboration and your help.
If someone knows if it's possible to use "ShellExecute"
(not workbooks.open) to open a file in the same instance
of the application where the macro is ? If yes, How to do it ?
'API
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
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'-----------------------------------------
Sub ShellOpenFile()
Const SW_SHOWNORMAL = 1
Dim hwnd As Long
Dim File As String
File = "C:\Workbook2.xls"
hwnd = FindWindow(vbNullString, Application.Caption)
ShellExecute hwnd, "open", File, vbNullString, vbNullString, SW_SHOWDEFAULT
End Sub
'-----------------------------------------
Thanks for your collaboration and your help.