Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
IoM IoM is offline
external usenet poster
 
Posts: 4
Default Record macro to export xml

I recorded a macro with 3 steps:
1. add an Xml Map to the curent workbook and choose root of the Map
2. map cells in excel file to the coresponding fields in the Map
3. export Xml data

The error I got is: €śThe map could not be exported, so the data was not
exported€ť
The problem is that step 2 is not recorded. There are no lines of code to
map the excel cells to the specified XmlMap so the map can not be exported.
How to write the code?

My xml schema has
a root €“ a list €“ 2 elements: T and O
and excel has 2 columns: T and O. The two elements should be mapped to the
excel cells.

Obs.: if I repeat these steps manually it works but if I register the macro
I get error.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Record macro to export xml

please show us your code.

"IoM" wrote:

I recorded a macro with 3 steps:
1. add an Xml Map to the curent workbook and choose root of the Map
2. map cells in excel file to the coresponding fields in the Map
3. export Xml data

The error I got is: €śThe map could not be exported, so the data was not
exported€ť
The problem is that step 2 is not recorded. There are no lines of code to
map the excel cells to the specified XmlMap so the map can not be exported.
How to write the code?

My xml schema has
a root €“ a list €“ 2 elements: T and O
and excel has 2 columns: T and O. The two elements should be mapped to the
excel cells.

Obs.: if I repeat these steps manually it works but if I register the macro
I get error.

  #3   Report Post  
Posted to microsoft.public.excel.programming
IoM IoM is offline
external usenet poster
 
Posts: 4
Default Record macro to export xml

I looked for methods, properties to treat mapping xml - excel cells but did
not find them.
Code:
Sub Macro()

Dim strSchemaLocation As String
Dim obj1 As XmlMap

strSchemaLocation = "D:\2005.04-22\1.xsd"

'XmlMap Object Represents an XML map that has been added to a workbook.
' Use the Add method of the XmlMaps collection to add an XML map to a
workbook.
Set obj1 = ActiveWorkbook.XmlMaps.Add(strSchemaLocation, _
"dataroot")
obj1.Name = "dataroot_Map"

Application.DisplayXMLSourcePane obj1

'My xml schema has a root - a list with 2 elements: T and O
'that should be mapped to T and O excel columns
'no code here €“ I guess here is the error

' Use the Export method to export data from cells mapped to the specified
XmlMap.
ActiveWorkbook.XmlMaps("dataroot_Map").Export URL:= _
"D:\2005.04-22\1.xml", _
OVERWRITE:=True

Application.CommandBars("Task Pane").Visible = True

End Sub


"Patrick Molloy" wrote:

please show us your code.

"IoM" wrote:

I recorded a macro with 3 steps:
1. add an Xml Map to the curent workbook and choose root of the Map
2. map cells in excel file to the coresponding fields in the Map
3. export Xml data

The error I got is: €śThe map could not be exported, so the data was not
exported€ť
The problem is that step 2 is not recorded. There are no lines of code to
map the excel cells to the specified XmlMap so the map can not be exported.
How to write the code?

My xml schema has
a root €“ a list €“ 2 elements: T and O
and excel has 2 columns: T and O. The two elements should be mapped to the
excel cells.

Obs.: if I repeat these steps manually it works but if I register the macro
I get error.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Record macro to export xml

Hi IoM,

I looked for methods, properties to treat mapping xml - excel cells but did
not find them.


You use the Range.Path.SetValue or ListColumn.XPath.SetValue to map a single
cell or a column of a List to an XML Map.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev


  #5   Report Post  
Posted to microsoft.public.excel.programming
IoM IoM is offline
external usenet poster
 
Posts: 4
Default Record macro to export xml

Thanks. I used ListColumn.XPath.SetValue and it worked.

Now i have another question:
Why Excel exports 65535 lines(maximum number) instead of only those with
useful data?
Because of that after export i have to open the xml file by hand and delete
all empty lines.
It will be nice to eliminate this manual operation.

"Stephen Bullen" wrote:

Hi IoM,

I looked for methods, properties to treat mapping xml - excel cells but did
not find them.


You use the Range.Path.SetValue or ListColumn.XPath.SetValue to map a single
cell or a column of a List to an XML Map.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Record macro to export xml

Hi IoM,

Why Excel exports 65535 lines(maximum number) instead of only those with
useful data?


It certainly shouldn't do! I guess it depends how you created and defined
your List object.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev


  #7   Report Post  
Posted to microsoft.public.excel.programming
IoM IoM is offline
external usenet poster
 
Posts: 4
Default Record macro to export xml

I also think it should not do so. BUT, i also tried mapping by hand in Excel
(not with macro). It was the same result. The problem is inside Excel i
think. I need a way to trick it :).

My conclusion:
If you try to map an element of the map to a cell, a range of cells of the
same column or to a whole column the result is the same. It mapps the column
to the element of the map, that means it exports the whole column, 65535 line
no matter useful data.

"Stephen Bullen" wrote:

Hi IoM,

Why Excel exports 65535 lines(maximum number) instead of only those with
useful data?


It certainly shouldn't do! I guess it depends how you created and defined
your List object.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Record macro to export xml

Hi IoM,

If you try to map an element of the map to a cell, a range of cells of the
same column or to a whole column the result is the same. It mapps the column
to the element of the map, that means it exports the whole column, 65535 line
no matter useful data.


That's not what I see here. If I map an element to a cell, I only get one item
exported. If I create a List on the sheet and map an element to a column in the
list, I get an item for each row of the list, but no more.

Regards

Stephen Bullen
Microsoft MVP - Excel

Professional Excel Development
The most advanced Excel VBA book available
www.oaltd.co.uk/ProExcelDev


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
Export Single Record to Append to Access Table RMS Excel Discussion (Misc queries) 1 December 9th 08 07:08 PM
Export Access Record to Specific Cells in Excel Elecdave Excel Discussion (Misc queries) 0 December 29th 04 04:49 PM
Record Macro - Record custom user actions Sal[_4_] Excel Programming 1 December 23rd 04 03:18 PM
Export CSV; first three rows contain record map DW[_3_] Excel Programming 1 November 29th 04 07:18 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM


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

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

About Us

"It's about Microsoft Excel"