Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default appending to excel file

Hello All,
I have a macro that opens a file ,copies it's contents and then writes
those contents to the excel document that is running the macro and is
therefore already open. This works however I want to actually append
the data that it's copying to my open excel file as my macro loops
through a directory and i take specific info from each file and want to
make a master file with ALL the contents in it. Currently my macro
overwrites the data so i always only have 1 row where there should be
1000's of rows. Any idea's on what i am doing wrong,
Here is the code.


Sub XML_DATA_LOAD()

'Load the XML and the XSL (the stylesheet).
Dim varFileArray As Variant
Dim oXML As Object, oXSL As Object
Dim rngMaster As Range
Dim rngData As Range
Dim shtMaster As Worksheet
Set oXML = CreateObject("MSXML.DOMDocument")
Set oXSL = CreateObject("MSXML.DOMDocument")

Dim PathToUse As String
Dim myFile As String

PathToUse = "C:\test\"

varFileArray = GetAllFilesInDir(PathToUse)
For lngI = 0 To UBound(varFileArray)
Debug.Print varFileArray(lngI)
oXML.Load PathToUse & varFileArray(lngI)

oXSL.Load "C:\Marine.xslt"

Dim sHTML As String
sHTML = oXML.transformNode(oXSL)

Open "c:\temp.html" For Output As #1
Print #1, sHTML
Close #1

Sheets("XML Data").Select
Range("A1").Select

Workbooks.Open Filename:="c:\temp.html"

Range("A1:A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range("A1:BA2").Select
Selection.Copy

With Workbooks(1)
.Activate
Sheets("XML Data").Select
Selection.PasteSpecial Paste:=xlPasteAll,
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

End With

Workbooks(2).Save
Workbooks(2).Close True

Next lngI



End Sub

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
appending one Excel file to another ? George Lewycky Excel Worksheet Functions 2 November 14th 08 07:37 PM
Appending an Excel File to another Wisconsin Excel Discussion (Misc queries) 0 April 14th 08 07:38 PM
Appending a second csv file Rick Excel Discussion (Misc queries) 3 March 9th 05 06:21 PM
Appending to File Progster Excel Programming 1 September 22nd 03 02:24 PM
Appending Excel file to an Access table Diana[_5_] Excel Programming 1 September 10th 03 08:21 AM


All times are GMT +1. The time now is 08:31 AM.

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"