Click here to Skip to main content
11,806,931 members (62,731 online)
Rate this: bad
Please Sign up or sign in to vote.
I've recently updated our PCs to run Windows 7 32-bit from Windows XP. The code I had used in the past has stopped working and I was wondering what I could do to get it working again.

FileStr.Format("Microsoft Excel - %s  [Read-Only]", pathStr);
HWND hWnd= ::FindWindow(NULL,FileStr);
if (hWnd == NULL)
	ShellExecute(NULL, "open", pseMULTI.m_tProductionTaskfBriefPath, NULL, NULL, SW_SHOWNORMAL);

Obviously Windows have changed the way it window names, and I appreciate that the way I had been doing it was a complete fudge.

Any help appreciated.

Posted 7-Feb-13 23:22pm
Edited 7-Feb-13 23:26pm
Matthew Faithfull at 8-Feb-13 5:30am
You might have more luck going the COM route, using the Running Object Table to find instances of the root Excel Application Object. You'd need it's ClassId which is public and some IROT client code. I've never actually done it although I've several times thought I would need to and then found an easier way. Maybe that's an indication that you will too.
Richard MacCutchan at 8-Feb-13 5:34am
Try opening the file manually with Excel, and check the string you are using is valid. If it still fails then use your debugger to step through your code and see exactly what is happening.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Check for the windows version and do it the "Windows 7" way.

Use Spy++ to detect the right name of the excel-doc
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

You must check Process in Task manager by VC++ and use for statement. use GetmoduleFilename and GetModuleHandle.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 ppolymorphe 225
1 Afzaal Ahmad Zeeshan 165
2 OriginalGriff 150
3 George Jonsson 145
4 CPallini 100
0 OriginalGriff 3,405
1 Maciej Los 1,990
2 CPallini 1,955
3 KrunalRohit 1,907
4 ppolymorphe 1,407

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100