Click here to Skip to main content
15,913,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Database work in Visual C++ Pin
David Crow3-Sep-04 7:14
David Crow3-Sep-04 7:14 
QuestionActiveX TypeLib Practices: property or method? Pin
KFournier3-Sep-04 6:28
KFournier3-Sep-04 6:28 
GeneralHey i am looking for real MSGINA code Pin
ThatsAlok3-Sep-04 6:21
ThatsAlok3-Sep-04 6:21 
GeneralRe: Hey i am looking for real MSGINA code Pin
Michael Dunn3-Sep-04 7:18
sitebuilderMichael Dunn3-Sep-04 7:18 
GeneralRe: Hey i am looking for real MSGINA code Pin
ThatsAlok3-Sep-04 19:44
ThatsAlok3-Sep-04 19:44 
GeneralRe: Hey i am looking for real MSGINA code Pin
David Crow7-Sep-04 7:51
David Crow7-Sep-04 7:51 
GeneralRe: Hey i am looking for real MSGINA code Pin
ThatsAlok7-Sep-04 23:09
ThatsAlok7-Sep-04 23:09 
Generalexcel automation!! Pin
pnpfriend3-Sep-04 5:56
pnpfriend3-Sep-04 5:56 
Hello All excel Automation expert,
I'm having trouble closing excel application. It physically closed.. but the TaskManager Process shows the Excel Process is still running.

The program wait for the excel application to be close by user.. it is waiting forever since the Excel process is still running. How to close the excel application totally?

Is there anyway, not closing excel application and waiting for the user to finish formating or whatever he/she has to do with the worksheet then let the user close the excel file (not excel application). As soon as program knows the user just close the excel ( again , not excel application), the program can open new excel file in the same application?
Thank you.

<br />
ReleaseAllDispatch();<br />
WaitForExcelToClose();<br />
<br />

<br />
void CDlg::WaitForExcelToClose()<br />
{<br />
    HWND hWnd;<br />
    char buf[1024];<br />
    hWnd = ::FindWindow(TEXT("XLMain"),NULL);<br />
    if(NULL==hWnd)<br />
    {<br />
      return;<br />
    }<br />
	<br />
    DWORD pid;<br />
    DWORD dThread;<br />
    DWORD dwReason;<br />
    dThread = ::GetWindowThreadProcessId(hWnd,&pid);<br />
    HANDLE hProcess;<br />
    hProcess = ::OpenProcess(SYNCHRONIZE|PROCESS_ALL_ACCESS,TRUE,pid);<br />
    pid = NULL;<br />
    dwReason = ::WaitForSingleObject(hProcess,INFINITE);<br />
    ::CloseHandle(hProcess);   <br />
}



<br />
void CDlg::ReleaseAllDispatch(){<br />
range.DetachDispatch();    <br />
pagesetup.DetachDispatch();<br />
sheet.DetachDispatch();	<br />
sheets.DetachDispatch();<br />
book.DetachDispatch();   	<br />
app.DetachDispatch();<br />
<br />
book.ReleaseDispatch();		<br />
books.ReleaseDispatch();		<br />
range.ReleaseDispatch();	<br />
pagesetup.ReleaseDispatch();    <br />
sheet.ReleaseDispatch();    <br />
sheets.ReleaseDispatch();				<br />
app.Quit();    <br />
<br />
app=NULL;		<br />
pagesetup = NULL;<br />
range = NULL;<br />
book = NULL;<br />
books = NULL;<br />
sheet = NULL;<br />
sheets = NULL;<br />
<br />
CoUninitialize();  //unintializing the OLE*/<br />
}<br />

GeneralRe: excel automation!! Pin
David Crow3-Sep-04 6:11
David Crow3-Sep-04 6:11 
GeneralRe: excel automation!! Pin
pnpfriend3-Sep-04 6:56
pnpfriend3-Sep-04 6:56 
GeneralRe: excel automation!! Pin
David Crow3-Sep-04 7:02
David Crow3-Sep-04 7:02 
GeneralRe: excel automation!! Pin
pnpfriend3-Sep-04 9:02
pnpfriend3-Sep-04 9:02 
GeneralRe: excel automation!! Pin
David Crow3-Sep-04 9:42
David Crow3-Sep-04 9:42 
GeneralRe: excel automation!! Pin
pnpfriend7-Sep-04 7:33
pnpfriend7-Sep-04 7:33 
GeneralActivate a specific View in an MDI MFC Doc/View App Pin
Paul Steane3-Sep-04 5:28
Paul Steane3-Sep-04 5:28 
GeneralRunning an .exe programmatically Pin
anderslundsgard3-Sep-04 5:13
anderslundsgard3-Sep-04 5:13 
GeneralRe: Running an .exe programmatically Pin
David Crow3-Sep-04 6:12
David Crow3-Sep-04 6:12 
GeneralRe: Running an .exe programmatically Pin
Michael Dunn3-Sep-04 7:20
sitebuilderMichael Dunn3-Sep-04 7:20 
GeneralReplace Minimize Button Pin
Caligulo3-Sep-04 4:34
Caligulo3-Sep-04 4:34 
GeneralRe: Replace Minimize Button Pin
Maximilien3-Sep-04 5:10
Maximilien3-Sep-04 5:10 
GeneralSending characters to other windows Pin
tab13-Sep-04 4:28
tab13-Sep-04 4:28 
GeneralRe: Sending characters to other windows Pin
David Crow3-Sep-04 4:39
David Crow3-Sep-04 4:39 
GeneralRe: Sending characters to other windows Pin
tab13-Sep-04 4:42
tab13-Sep-04 4:42 
GeneralRe: Sending characters to other windows Pin
David Crow3-Sep-04 4:51
David Crow3-Sep-04 4:51 
GeneralRe: Sending characters to other windows Pin
tab13-Sep-04 4:58
tab13-Sep-04 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.