LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Open a file in the same instance with ShellExecute

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.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open new instance of excel every time I click file VIPGeorge Excel Discussion (Misc queries) 5 August 16th 12 07:57 PM
How to open a new instance of EXCEL and .xls file Launchnet Excel Worksheet Functions 10 June 19th 07 03:45 PM
How to open a new instance of Word and its .doc file Launchnet Excel Worksheet Functions 3 June 18th 07 06:20 PM
ShellExecute hangs Excel when opening XLS file [email protected] Excel Programming 5 January 3rd 07 06:35 AM
I would like to open a new instance of Excel each time I double-click on a xls file Mark Excel Worksheet Functions 4 September 1st 05 02:29 PM


All times are GMT +1. The time now is 10:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"