1
votes

I've been struggling bringing OneNote to the foreground using OLE automation. When I run the following code, OneNote loads in the background and I'm not able to bring it to the foreground. I haven't had any problems trying to launch and bring Word, Excel, PowerPoint and Edge to the foreground, however OneNote behaves different. There is very little info about OneNote being automated using OLE and some pages are not longer exist.

Any help would be appreciated. You can download the Onenote14-x86.h file from here

#include "stdafx.h"
#include "onenote14-x86.h"

 int _tmain(int argc, _TCHAR* argv[])

 {    
 CoInitialize(NULL);

 IApplication* piOneNote;

 CoCreateInstance(__uuidof(Application), NULL, CLSCTX_LOCAL_SERVER, __uuidof(IApplication), (void**)&piOneNote);

 if(piOneNote)
 {

 BSTR temp; 

 HRESULT hr = piOneNote->GetHierarchy(NULL, hsNotebooks, &temp);

 } 
 }
1
try piOneNote->NavigateTo(NULL, NULL, VARIANT_TRUE); for exampleSimon Mourier
Sir Simon, you are a G-E-N-I-O-U-S!! thank you!!!!Febo Jarlock

1 Answers

1
votes

You can create a new windows with this call

piOneNote->NavigateTo(NULL, NULL, VARIANT_TRUE);