Click here to Skip to main content
13,510,525 members
Rate this:
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
Updated 7-Feb-13 23:26pm
Matthew Faithfull 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 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

Hi 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180417.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2018
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