Trouble with FindExecutable and Excel on NT 4.0

Hi:

I have some code for spawning Excel from my VB3 app.
It runs successfully on dozens of PCs, under all flavors of Windows.

I now have a Windows NT 4.0 user for which the code doesn't fully work.

after setting strFullExcelPathAndName = "C:\CIRCLY4\apsdsxl5.xls"

the API call
r = FindExecutable(strFullExcelPathAndName, "C:\", strEXCELPath)

gives strEXCELPath = "C:\RECYCLED\DC1\EXCEL.EXE"

then:

with strFullExcelCommandLine = "C:\RECYCLED\DC1\EXCEL.EXE  /p C:\CIRCLY4 C:\CIRCLY4\apsdsxl5.xls"

r = WinExec(strFullExcelCommandLine, 2)

returns r=3 (Invalid path error).

My user can double click on a .xls file from File Explorer and Excel starts OK.

Help please?

Regards

Leigh
LVL 1
LeighWardleAsked:
Who is Participating?
 
chensuConnect With a Mentor Commented:
Instead of using FindExecutable and WinExec, simply call ShellExecute.

ShellExecute(hWnd, NULL, strFullExcelPathAndName, NULL, NULL, SW_SHOWNORMAL);

The reason why WinExec fails with that particular command line is likely that there is ambiguity due to long file names. You may also try using CreateProcess with executable name and command line parameters seperately.
0
All Courses

From novice to tech pro — start learning today.