View Single Post
  #1   Report Post  
Old September 1st 06, 05:04 AM posted to microsoft.public.excel.programming
[email protected] jhcoxx@hotmail.com is offline
external usenet poster
 
First recorded activity by ExcelBanter: Jan 2008
Posts: 9
Default Shell Doesn't Work With UNC - Can't Get ShellExecute to Work Either

Problem: Need to display in the Windows Picture and Fax Viewer a .png
file that resides on a server - and I can't count on every user having
..png's associated with that viewer. For a local .png file or one on a
server mapped to a drive letter the following Shell command works:

strCmdLine = "rundll32.exe shimgvw.dll,ImageView_Fullscreen
C:\20060301cskdz-a-p.jpg"
lRetVal = Shell(strCmdLine, vbNormalFocus)

but, since I can't be sure all users will have the server mapped to the
same letter, I need to use a UNC pathname - and Shell can't deal with
UNC paths.

From what I've been able to find, it looks like the ShellExecute API

ought to be what's needed, with the definition of (from
http://support.microsoft.com/kb/170918/en-us)

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


The following table provides descriptions for each parameter:
Parameter Description
----------------------------------------------------------------------------
hwnd Identifies the parent window. This window receives any
message boxes an application produces (for example, for
error
reporting).

lpszOp Points to a null-terminated string specifying the
operation
to perform. This string can be "open" or "print." If this
parameter is NULL, "open" is the default value.

lpszFile Points to a null-terminated string specifying the file
to open.

lpszParams Points to a null-terminated string specifying parameters
passed to the application when the lpszFile parameter
specifies an executable file. If lpszFile points to a
string
specifying a document file, this parameter is NULL.

LpszDir Points to a null-terminated string specifying the default
directory.

FsShowCmd Specifies whether the application window is to be shown
when
the application is opened.

But I've been unable to untangle what parts of

"rundll32.exe shimgvw.dll,ImageView_Fullscreen
C:\20060301cskdz-a-p.jpg"

go into which part of the ShellExecute call.

Anyone know? I've lost track of all the combinations that I've tried

Thanks in advance for any help on this!

James Cox