Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Win7 Excel Process
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:22pm
Edited 7-Feb-13 23:26pm
v2
Comments
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
good
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
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 474
1 OriginalGriff 388
2 Maciej Los 385
3 CPallini 194
4 CHill60 180
0 OriginalGriff 6,152
1 Sergey Alexandrovich Kryukov 5,312
2 Maciej Los 3,279
3 Peter Leow 3,184
4 DamithSL 2,490


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2014
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