Click here to Skip to main content
Sign Up to vote bad
good
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.
 
Thanks.
Posted 7 Feb '13 - 23:22
Edited 7 Feb '13 - 23:26

Comments
Matthew Faithfull - 8 Feb '13 - 5:30
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:34
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.

2 solutions

Check for the windows version and do it the "Windows 7" way.
 
Use Spy++ to detect the right name of the excel-doc
  Permalink  
Hi
You must check Process in Task manager by VC++ and use for statement. use GetmoduleFilename and GetModuleHandle.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 8,386
1 OriginalGriff 6,596
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid