VB6 & OneNote 1.1 Type Library

T

Tim Owers

The following VB6 code returns error Method 'Import' of object
'ISimpleImporter' failed...
_______________________________________________________
Sub OneNote_ImportXML()
Dim strFileName As String
Dim strImportXml As String
Dim objOneNote As OneNote.CSimpleImporter

CommonDialog1.Filter = "XML files (*.XML)|*.XML|Text files (*.TXT)|*.TXT"
CommonDialog1.ShowOpen
strFileName = CommonDialog1.FileName

Set objOneNote = New OneNote.CSimpleImporter

Open (strFileName) For Input As #1
strImportXml = Input(LOF(1), #1)
Close #1

objOneNote.Import strImportXml ' generates a Method 'Import' of object
'ISimpleImporter' failed here

End Sub
_______________________________________________________
Any ideas as to why this fails?
 
K

Kathy J

Not off the top of my head. However, you might be interested in an article
recently added to Mr. Excel's site (he and I have a OneNote book coming out
later this year). He has done some work on getting Office Apps (specifically
Excel) to work with the Import method. It's VBA, not VB, but you might find
it useful anyway. Check it out at:
http://www.mrexcel.com/tip078.shtml


--
Kathryn Jacobs, Microsoft MVP PowerPoint and OneNote
Co-Author of Life on OneNote - Coming Dec 2004 from Holy Macro! Books
Get OneNote answers at http://www.onenoteanswers.com
Get PowerPoint answers at http://www.powerpointanswers.com
Want to learn OneNote? Check out
http://www.eclecticacademy.com/newclasses.htm#onenote

I believe life is meant to be lived. But:
if we live without making a difference, it makes no difference that we lived
 
T

Tim Owers

Thanks for the reply Kathryn,
Even modifying the example VBA code from the site you mentioned still
generates a
Method 'Import' of object 'ISimpleImporter' failed
error.
Oh well :-(
 
D

David Rasmussen [MS]

Tim,
Unfortunately that error message isn't very informative. If you could get
the HRESULT from COM that would tell us what failed (I'm not sure if / how
you can get this from VB6). Alternatively can you post a simple XML file that
you're trying to import and we can see if there are obvious problems in
there. It's possible that there is an error in the XML.

I assume you're using OneNote 2003 SP1.

One important thing to check is that the namespace is right. It should be
http://schemas.microsoft.com/office/onenote/2004/import

Note that there is no "01/2004" in this. While the product was in
development this had a "01" in it which is part of the naming convention we
use for interim schemas. The final version is just "..onenote/2004.."
 
T

Tim Owers

Hello David,
Well! Your prompt regarding the XML validity revealed the problem was indeed
with the XML.
In my XML the EnsurePage path GUID differed to that in PlaceObjects
pagePath.
Once they matched, hey presto! All I need do now is work out the intricacies
of section color, specifying stationary etc.
Many regards,
Tim Owers.
 
D

David Rasmussen [MS]

Glad to here this helped.
Cheers,
David

Tim Owers said:
Hello David,
Well! Your prompt regarding the XML validity revealed the problem was indeed
with the XML.
In my XML the EnsurePage path GUID differed to that in PlaceObjects
pagePath.
Once they matched, hey presto! All I need do now is work out the intricacies
of section color, specifying stationary etc.
Many regards,
Tim Owers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top