Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm running the following code in Excel 2003 on Windows XP:
Dim calllms As String calllms = "C:\LEICA\LMSASCII.EXE " calllms = calllms & lblNewFilename.Caption + ".NA0" taskid = Shell(calllms) Most of the time this works, but sometimes I get runtime error 5, Invalid procedure or function call, when the Shell function is executed. The variable calllms evaluates to "C:\LEICA\LMSASCII.EXE C:\DOCUME~1\CHAMAK~1\LOCALS~1 \Temp\tmpa0n.NA0" with no spaces in the file name. If I copy this string and execute it from the run command under Start, there are no problems whatsoever. I've tried ShellExecute as well, as it is also inconsistent. Any ideas about what might be the problem? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"C:\LEICA\LMSASCII.EXE C:\DOCUME~1\CHAMAK~1\LOCALS~1
\Temp\tmpa0n.NA0" Sure that's correct ? With spaces after "LOCALS~1". Also, this file is in the temp folder. Are you sure it exists before the call is made ? Also, how are you getting this short name ? With the API GetShortPathName ? NickHK "HC Hamaker" wrote in message ... I'm running the following code in Excel 2003 on Windows XP: Dim calllms As String calllms = "C:\LEICA\LMSASCII.EXE " calllms = calllms & lblNewFilename.Caption + ".NA0" taskid = Shell(calllms) Most of the time this works, but sometimes I get runtime error 5, Invalid procedure or function call, when the Shell function is executed. The variable calllms evaluates to "C:\LEICA\LMSASCII.EXE C:\DOCUME~1\CHAMAK~1\LOCALS~1 \Temp\tmpa0n.NA0" with no spaces in the file name. If I copy this string and execute it from the run command under Start, there are no problems whatsoever. I've tried ShellExecute as well, as it is also inconsistent. Any ideas about what might be the problem? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There are no spaces in the file name, including the path. The line break is
created by this forum text box. I am sure the file exists. I create it myself. I have verified it both by looking at Windows Explorer and by copying the value of the calllms string during debugging, pressing the Start button, the Run..., pasting the string in the text box in the window, and running it successfully. I get the path for the temp directory using the statement temppath = Environ$("TEMP") Hope this gives you some clues. Thanks. "NickHK" wrote: "C:\LEICA\LMSASCII.EXE C:\DOCUME~1\CHAMAK~1\LOCALS~1 \Temp\tmpa0n.NA0" Sure that's correct ? With spaces after "LOCALS~1". Also, this file is in the temp folder. Are you sure it exists before the call is made ? Also, how are you getting this short name ? With the API GetShortPathName ? NickHK "HC Hamaker" wrote in message ... I'm running the following code in Excel 2003 on Windows XP: Dim calllms As String calllms = "C:\LEICA\LMSASCII.EXE " calllms = calllms & lblNewFilename.Caption + ".NA0" taskid = Shell(calllms) Most of the time this works, but sometimes I get runtime error 5, Invalid procedure or function call, when the Shell function is executed. The variable calllms evaluates to "C:\LEICA\LMSASCII.EXE C:\DOCUME~1\CHAMAK~1\LOCALS~1 \Temp\tmpa0n.NA0" with no spaces in the file name. If I copy this string and execute it from the run command under Start, there are no problems whatsoever. I've tried ShellExecute as well, as it is also inconsistent. Any ideas about what might be the problem? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Upon further research, I believe the underlying cause is that the application
I'm trying to start is 16-bit program, and the Shell function will choke on that (even though it usually doesn't). The documentation says the workaround is to use a 32-bit application to call 16-bit application, and use the Shell function to start the 32-bit application. Does anyone have a suggestion on how to do that? For example, does anyone know how to call the StartRun... on the task bar from VBA? "HC Hamaker" wrote: There are no spaces in the file name, including the path. The line break is created by this forum text box. I am sure the file exists. I create it myself. I have verified it both by looking at Windows Explorer and by copying the value of the calllms string during debugging, pressing the Start button, the Run..., pasting the string in the text box in the window, and running it successfully. I get the path for the temp directory using the statement temppath = Environ$("TEMP") Hope this gives you some clues. Thanks. "NickHK" wrote: "C:\LEICA\LMSASCII.EXE C:\DOCUME~1\CHAMAK~1\LOCALS~1 \Temp\tmpa0n.NA0" Sure that's correct ? With spaces after "LOCALS~1". Also, this file is in the temp folder. Are you sure it exists before the call is made ? Also, how are you getting this short name ? With the API GetShortPathName ? NickHK "HC Hamaker" wrote in message ... I'm running the following code in Excel 2003 on Windows XP: Dim calllms As String calllms = "C:\LEICA\LMSASCII.EXE " calllms = calllms & lblNewFilename.Caption + ".NA0" taskid = Shell(calllms) Most of the time this works, but sometimes I get runtime error 5, Invalid procedure or function call, when the Shell function is executed. The variable calllms evaluates to "C:\LEICA\LMSASCII.EXE C:\DOCUME~1\CHAMAK~1\LOCALS~1 \Temp\tmpa0n.NA0" with no spaces in the file name. If I copy this string and execute it from the run command under Start, there are no problems whatsoever. I've tried ShellExecute as well, as it is also inconsistent. Any ideas about what might be the problem? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Would kicking off a batch file instead do the trick for you?
tbone On Fri, 1 Jun 2007 16:18:01 -0700, HC Hamaker wrote: Upon further research, I believe the underlying cause is that the application I'm trying to start is 16-bit program, and the Shell function will choke on that (even though it usually doesn't). The documentation says the workaround is to use a 32-bit application to call 16-bit application, and use the Shell function to start the 32-bit application. Does anyone have a suggestion on how to do that? For example, does anyone know how to call the StartRun... on the task bar from VBA? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After some research, I've found that using the CreateProcess() API seems to
solve the problem. Unlike ShellExecute(), it doesn't care whether the application is 32- or 16-bit. The documentation of it notes that Windows 95 and NT have to be treated differently; for my XP application, the latter was the proper choice. Thanks to you folks for your interest in my problem. "tbone" wrote: Would kicking off a batch file instead do the trick for you? tbone On Fri, 1 Jun 2007 16:18:01 -0700, HC Hamaker wrote: Upon further research, I believe the underlying cause is that the application I'm trying to start is 16-bit program, and the Shell function will choke on that (even though it usually doesn't). The documentation says the workaround is to use a 32-bit application to call 16-bit application, and use the Shell function to start the 32-bit application. Does anyone have a suggestion on how to do that? For example, does anyone know how to call the StartRun... on the task bar from VBA? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Shell function | Excel Programming | |||
Shell function | Excel Programming | |||
Shell function II | Excel Programming | |||
Shell function II | Excel Programming | |||
Shell function | Excel Programming |