Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Loading xml files

Hello - I have had luck loading xml files using the following declaration and
assignment in the sub routine:

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.Load ("G:\CatTree.xml")

However, I have downloaded a sample excel file that makes the following
declaration in the declarations section of the module:

Dim catTree As MSXML2.DOMDocument

And later in the sub routine, the file is loaded with the following code:

Set catTree = New Msxml2.DOMDocument
catTree.async = False
catTree.Load (catTreeFileLocation)

What is the difference between the two ways of handling xml. The reason I
ask is that the 2nd example works just fine in the excel file that I
downloaded. But if I try to duplicate in any other file, I get a compile
error: "User-defined type not defined." at the module level declaration.
What could be the difference between the file I downloaded and a file I
create myself? I'm talking about duplicating the whole project so that there
is no difference... I still get the compile error.
--
Thanks,
Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loading xml files

It sounds like the error is caused because you have not created a reference
to the library that defines MSXML2

in the workbook that workds, go into the VBE and with that workbook as the
activeproject in the vbe (selected in the project explorer window), go into
Tools=References. You should see a reference to Microsoft XML, ver x.x

where x.x will be the version number. Then you can go to the object
browser and select MSXML2 and see the objects such as DOMDocument.

So in your other applications, you will need to set the reference to use the
second approach. The first approach you show is called late binding and
avoids the need to set the reference.

--
Regards,
Tom Ogilvy


"Mike Archer" wrote in message
...
Hello - I have had luck loading xml files using the following declaration

and
assignment in the sub routine:

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.Load ("G:\CatTree.xml")

However, I have downloaded a sample excel file that makes the following
declaration in the declarations section of the module:

Dim catTree As MSXML2.DOMDocument

And later in the sub routine, the file is loaded with the following code:

Set catTree = New Msxml2.DOMDocument
catTree.async = False
catTree.Load (catTreeFileLocation)

What is the difference between the two ways of handling xml. The reason I
ask is that the 2nd example works just fine in the excel file that I
downloaded. But if I try to duplicate in any other file, I get a compile
error: "User-defined type not defined." at the module level declaration.
What could be the difference between the file I downloaded and a file I
create myself? I'm talking about duplicating the whole project so that

there
is no difference... I still get the compile error.
--
Thanks,
Mike



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Loading xml files

Great! That works now. BTW - Are there any disadvantages to using the late
binding approach? I like not having to worry about setting the library
reference.
--
Thanks,
Mike


"Tom Ogilvy" wrote:

It sounds like the error is caused because you have not created a reference
to the library that defines MSXML2

in the workbook that workds, go into the VBE and with that workbook as the
activeproject in the vbe (selected in the project explorer window), go into
Tools=References. You should see a reference to Microsoft XML, ver x.x

where x.x will be the version number. Then you can go to the object
browser and select MSXML2 and see the objects such as DOMDocument.

So in your other applications, you will need to set the reference to use the
second approach. The first approach you show is called late binding and
avoids the need to set the reference.

--
Regards,
Tom Ogilvy


"Mike Archer" wrote in message
...
Hello - I have had luck loading xml files using the following declaration

and
assignment in the sub routine:

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.Load ("G:\CatTree.xml")

However, I have downloaded a sample excel file that makes the following
declaration in the declarations section of the module:

Dim catTree As MSXML2.DOMDocument

And later in the sub routine, the file is loaded with the following code:

Set catTree = New Msxml2.DOMDocument
catTree.async = False
catTree.Load (catTreeFileLocation)

What is the difference between the two ways of handling xml. The reason I
ask is that the 2nd example works just fine in the excel file that I
downloaded. But if I try to duplicate in any other file, I get a compile
error: "User-defined type not defined." at the module level declaration.
What could be the difference between the file I downloaded and a file I
create myself? I'm talking about duplicating the whole project so that

there
is no difference... I still get the compile error.
--
Thanks,
Mike




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loading xml files

It is slower and in development, you don't get intellisense. However, it
isn't a lot slower.

A lot of people use early binding for development, then switch to late
binding for distribution to avoid version problems with library references.

--
Regards,
Tom Ogilvy

"Mike Archer" wrote in message
...
Great! That works now. BTW - Are there any disadvantages to using the

late
binding approach? I like not having to worry about setting the library
reference.
--
Thanks,
Mike


"Tom Ogilvy" wrote:

It sounds like the error is caused because you have not created a

reference
to the library that defines MSXML2

in the workbook that workds, go into the VBE and with that workbook as

the
activeproject in the vbe (selected in the project explorer window), go

into
Tools=References. You should see a reference to Microsoft XML, ver

x.x

where x.x will be the version number. Then you can go to the object
browser and select MSXML2 and see the objects such as DOMDocument.

So in your other applications, you will need to set the reference to use

the
second approach. The first approach you show is called late binding and
avoids the need to set the reference.

--
Regards,
Tom Ogilvy


"Mike Archer" wrote in message
...
Hello - I have had luck loading xml files using the following

declaration
and
assignment in the sub routine:

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.Load ("G:\CatTree.xml")

However, I have downloaded a sample excel file that makes the

following
declaration in the declarations section of the module:

Dim catTree As MSXML2.DOMDocument

And later in the sub routine, the file is loaded with the following

code:

Set catTree = New Msxml2.DOMDocument
catTree.async = False
catTree.Load (catTreeFileLocation)

What is the difference between the two ways of handling xml. The

reason I
ask is that the 2nd example works just fine in the excel file that I
downloaded. But if I try to duplicate in any other file, I get a

compile
error: "User-defined type not defined." at the module level

declaration.
What could be the difference between the file I downloaded and a file

I
create myself? I'm talking about duplicating the whole project so

that
there
is no difference... I still get the compile error.
--
Thanks,
Mike






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
trouble loading excel files Lonnie Excel Discussion (Misc queries) 0 February 5th 09 05:28 PM
Loading Excel files Guy Coleman Setting up and Configuration of Excel 2 March 14th 07 09:58 PM
loading txt files with more than 256 columns Pilgrim Excel Programming 4 March 18th 05 12:01 AM
Excel Automation - loading text files varsha kashyap Excel Programming 0 October 18th 04 10:13 AM


All times are GMT +1. The time now is 02:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"