A
Al Borges
Hi Folks:
After my earlier question went dead with nobody being able to figure out at
least one method of getting information from Word to OneNote, and after
seeing the same in chat rooms going back to 2004, I spent the past few days
figuring out 2 methods. So far, one works pretty well.
METHOD 1
-------------
1) copy a phrase, s.a. "SOAP NOTE 6/29/2005", then run the following code in
a clickbutton; this will be your TITLE.
2) Here's the code:
' bring up OneNote document and add in a new page
strpath = "c:\program files\microsoft office\office11\onenote.exe"
strswitch = " /new C:\onenoteimport.one"
strcmd = strpath & strswitch
Shell strcmd, vbMaximizedFocus
'paste in your TITLE phrase "SOAP NOTE 6/29/2005"
strswitch = " /paste"
strcmd = strpath & strswitch
Shell strcmd, vbMaximizedFocus
'TAB out of the TITLE field
SendKeys "%{TAB}", True
'copy your current Word document contents
Application.Selection.SetRange Start:=Selection.Start,
End:=ActiveDocument.Content.End
Application.Selection.Copy
'paste it
strswitch = " /paste"
strcmd = strpath & strswitch
Shell strcmd, vbMaximizedFocus
--------------------------------------------------------------------
METHOD 2
-------------
I'll be working on the CSimpleImporterClass method to do the same. It
supposedly offers more control, but it's tricky. I have yet to see anyone
really work with it outside of one Excel project that I found on the 'net
(http://www.mrexcel.com/tip078.shtml). I did find that one poster back in
December started to programmatically control OneNote through this method
(http://theofficeexperts.com/forum/showthread.php?t=3786). Here is his code,
but still no go since it breaks on the "brigitte":
--------------
Dim objOneNote As OneNote.CSimpleImporter
Set objOneNote = New OneNote.CSimpleImporter
'the folder name is "Cabinet"
'the page name is " brigitte " =>the third one on the list (3-brigitte )
' onenote 2003 sp1 show up with an error message
' the debugger stops on the next line
objOneNote.NavigateToPage "Cabinet.one", "brigitte"
End Sub
anyone can provide the right code
purpose is to navigate only ( display a specified page )
----------------
One error that I see is that instead of using the title "brigitte" you need
to put in a GUID expression. I tried rewriting the thing using an automatic
GUID generator (http://www.trigeminal.com/code/guids.bas), but it seems that
you need to use the actual OneNote active GUID pagenumber, including the one
given automatically to new pages. Anyone know how to get that?
Gosh, I'd like to break this code...
Thanks,
Al
After my earlier question went dead with nobody being able to figure out at
least one method of getting information from Word to OneNote, and after
seeing the same in chat rooms going back to 2004, I spent the past few days
figuring out 2 methods. So far, one works pretty well.
METHOD 1
-------------
1) copy a phrase, s.a. "SOAP NOTE 6/29/2005", then run the following code in
a clickbutton; this will be your TITLE.
2) Here's the code:
' bring up OneNote document and add in a new page
strpath = "c:\program files\microsoft office\office11\onenote.exe"
strswitch = " /new C:\onenoteimport.one"
strcmd = strpath & strswitch
Shell strcmd, vbMaximizedFocus
'paste in your TITLE phrase "SOAP NOTE 6/29/2005"
strswitch = " /paste"
strcmd = strpath & strswitch
Shell strcmd, vbMaximizedFocus
'TAB out of the TITLE field
SendKeys "%{TAB}", True
'copy your current Word document contents
Application.Selection.SetRange Start:=Selection.Start,
End:=ActiveDocument.Content.End
Application.Selection.Copy
'paste it
strswitch = " /paste"
strcmd = strpath & strswitch
Shell strcmd, vbMaximizedFocus
--------------------------------------------------------------------
METHOD 2
-------------
I'll be working on the CSimpleImporterClass method to do the same. It
supposedly offers more control, but it's tricky. I have yet to see anyone
really work with it outside of one Excel project that I found on the 'net
(http://www.mrexcel.com/tip078.shtml). I did find that one poster back in
December started to programmatically control OneNote through this method
(http://theofficeexperts.com/forum/showthread.php?t=3786). Here is his code,
but still no go since it breaks on the "brigitte":
--------------
Dim objOneNote As OneNote.CSimpleImporter
Set objOneNote = New OneNote.CSimpleImporter
'the folder name is "Cabinet"
'the page name is " brigitte " =>the third one on the list (3-brigitte )
' onenote 2003 sp1 show up with an error message
' the debugger stops on the next line
objOneNote.NavigateToPage "Cabinet.one", "brigitte"
End Sub
anyone can provide the right code
purpose is to navigate only ( display a specified page )
----------------
One error that I see is that instead of using the title "brigitte" you need
to put in a GUID expression. I tried rewriting the thing using an automatic
GUID generator (http://www.trigeminal.com/code/guids.bas), but it seems that
you need to use the actual OneNote active GUID pagenumber, including the one
given automatically to new pages. Anyone know how to get that?
Gosh, I'd like to break this code...
Thanks,
Al