View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Shell function sometimes works, sometimes doesn't

"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?