#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Open file

I've had valuable help from Ivyleaf and Peter T. (this discussion group) in
order to get the procedure below to open a document of any type. See routine
below. I have some further questions. Can anybody help?

1.
If the document I try to open is an excel sheet. It seems that the Sub
OpenFile is hanging and keeps on runing forever. My theory is the I will need
let the procedure open the file new window or something like that. Can
anybody suggest a solution.

2.
I was informed that
ShellExecute 0&, "open", FName _
, vbNullString, "C:\", SW_SHOWMAXIMIZED

would work with Excel 1997 and 2000. (It works fine except from opening
excel files)
Other versions (later?) would use Application.hwnd instead of 0&. Which
version would work with 0& and which version would require application.hwnd?
(I have version 9.0)

3. What does the different parts in the command
ShellExecute 0&, "open", FName _
, vbNullString, "C:\", SW_SHOWMAXIMIZED
mean. Especially what is "C:\" here.


Code:
Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" ( _
ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
Optional ByVal lpParameters As String, _
Optional ByVal lpDirectory As String, _
Optional ByVal nShowCmd As Long) As Long

Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2

Sub OpenFile(FName)
Dim FName As String

FName = "filename.pdf"

ShellExecute 0&, "open", FName _
, vbNullString, "C:\", SW_SHOWMAXIMIZED

End Sub

Reply
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
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Setting up and Configuration of Excel 0 April 23rd 09 08:53 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM


All times are GMT +1. The time now is 05:36 AM.

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

About Us

"It's about Microsoft Excel"