Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Shell Doesn't Work With UNC - Can't Get ShellExecute to Work Either

I may have it - will have to check at work tomorrow when I have access
to a file server.

stFile = "c:\20060301cskdz-a-p.jpg"

stFile = "C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscr een " &
stFile

lRet = apiShellExecute(0&, "Open", "rundll32.exe", _
stFile, vbNullString, 3&)

is doing the trick!

Something about shimgvw.dll only being able to be accessed via
rundll32.exe apparently has something to do with what's considered a
parameter for the exe...

James Cox


wrote:
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


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
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
GetObject method not work after Call Shell Method ben Excel Programming 8 February 21st 06 03:45 PM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM
List of commands that work with shell? quartz[_2_] Excel Programming 0 February 16th 05 03:05 PM


All times are GMT +1. The time now is 11:12 PM.

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"