1

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);

 } 
 }
2
  • try piOneNote->NavigateTo(NULL, NULL, VARIANT_TRUE); for example Commented Oct 27, 2020 at 8:07
  • Sir Simon, you are a G-E-N-I-O-U-S!! thank you!!!! Commented Oct 27, 2020 at 23:47

1 Answer 1

1

You can create a new windows with this call

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.