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

Hi!

Firstly, is there a macro to go through many subfolders and change the
extension of all the files? Or if I do that myself,
Is there a way to somehow get a macro to seek the XML files, if
they're all in groups separated by folders?
So, have the macro get the 1st file (using an XML map), edit it using
another macro, save and close, then go get the next folder?

I have a series of groups of XML files, all following the same XML Map
in Excel, and I want a macro to bring them in, group by group, saving
them as separate files.

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default importing XML files

Sub getxml()

Const myfolder As String = "c:\temp"

Set fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = _
fso.GetFolder(myfolder)

If folder.subfolders.Count 0 Then
For Each sf In folder.subfolders

If sf.Files.Count 0 Then
For Each file In sf.Files
If UCase(Right(file, 3)) = "XML" Then

'add code to open each file here.

End If

Next file
End If

Next sf
End If

End Sub


" wrote:

Hi!

Firstly, is there a macro to go through many subfolders and change the
extension of all the files? Or if I do that myself,
Is there a way to somehow get a macro to seek the XML files, if
they're all in groups separated by folders?
So, have the macro get the 1st file (using an XML map), edit it using
another macro, save and close, then go get the next folder?

I have a series of groups of XML files, all following the same XML Map
in Excel, and I want a macro to bring them in, group by group, saving
them as separate files.

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default importing XML files

On Jun 28, 12:30 pm, Joel wrote:
Sub getxml()

Const myfolder As String = "c:\temp"

Set fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = _
fso.GetFolder(myfolder)

If folder.subfolders.Count 0 Then
For Each sf In folder.subfolders

If sf.Files.Count 0 Then
For Each file In sf.Files
If UCase(Right(file, 3)) = "XML" Then

'add code to open each file here.

End If

Next file
End If

Next sf
End If

End Sub



" wrote:
Hi!


Firstly, is there a macro to go through many subfolders and change the
extension of all the files? Or if I do that myself,
Is there a way to somehow get a macro to seek the XML files, if
they're all in groups separated by folders?
So, have the macro get the 1st file (using an XML map), edit it using
another macro, save and close, then go get the next folder?


I have a series of groups of XML files, all following the same XML Map
in Excel, and I want a macro to bring them in, group by group, saving
them as separate files.


Thanks!- Hide quoted text -


- Show quoted text -


Thank you so much! When I try to implement that though, it says that
the 'path is not found' although I put the path where the files are
where it was written c:/temp. The path I put is where all the
subfolders are. What am I doing wrong?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default importing XML files

On Jun 28, 12:41 pm, wrote:
On Jun 28, 12:30 pm, Joel wrote:





Sub getxml()


Const myfolder As String = "c:\temp"


Set fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = _
fso.GetFolder(myfolder)


If folder.subfolders.Count 0 Then
For Each sf In folder.subfolders


If sf.Files.Count 0 Then
For Each file In sf.Files
If UCase(Right(file, 3)) = "XML" Then


'add code to open each file here.


End If


Next file
End If


Next sf
End If


End Sub


" wrote:
Hi!


Firstly, is there a macro to go through many subfolders and change the
extension of all the files? Or if I do that myself,
Is there a way to somehow get a macro to seek the XML files, if
they're all in groups separated by folders?
So, have the macro get the 1st file (using an XML map), edit it using
another macro, save and close, then go get the next folder?


I have a series of groups of XML files, all following the same XML Map
in Excel, and I want a macro to bring them in, group by group, saving
them as separate files.


Thanks!- Hide quoted text -


- Show quoted text -


Thank you so much! When I try to implement that though, it says that
the 'path is not found' although I put the path where the files are
where it was written c:/temp. The path I put is where all the
subfolders are. What am I doing wrong?- Hide quoted text -

- Show quoted text -


Ok, never mind, I figured that one what, but I'm still having trouble
figuring out the code to open the individual files, because the
extension first has to be changed, and it should only import the XMLs
according to the map I setup. Do have any idea on how to do this?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default importing XML files

The only time I get your error is if a put in a bad path or the path includes
a filename. It fails on the line

Set folder = _
fso.GetFolder(myfolder)

Make sure you are only putting in the path name without any file name.

" wrote:

On Jun 28, 12:30 pm, Joel wrote:
Sub getxml()

Const myfolder As String = "c:\temp"

Set fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = _
fso.GetFolder(myfolder)

If folder.subfolders.Count 0 Then
For Each sf In folder.subfolders

If sf.Files.Count 0 Then
For Each file In sf.Files
If UCase(Right(file, 3)) = "XML" Then

'add code to open each file here.

End If

Next file
End If

Next sf
End If

End Sub



" wrote:
Hi!


Firstly, is there a macro to go through many subfolders and change the
extension of all the files? Or if I do that myself,
Is there a way to somehow get a macro to seek the XML files, if
they're all in groups separated by folders?
So, have the macro get the 1st file (using an XML map), edit it using
another macro, save and close, then go get the next folder?


I have a series of groups of XML files, all following the same XML Map
in Excel, and I want a macro to bring them in, group by group, saving
them as separate files.


Thanks!- Hide quoted text -


- Show quoted text -


Thank you so much! When I try to implement that though, it says that
the 'path is not found' although I put the path where the files are
where it was written c:/temp. The path I put is where all the
subfolders are. What am I doing wrong?


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
Importing files JakeShipley2008 Excel Programming 0 June 21st 07 05:27 PM
importing csv files joelb Excel Discussion (Misc queries) 2 June 7th 06 04:53 PM
Importing CSV files Chris Excel Discussion (Misc queries) 4 June 22nd 05 03:02 PM
Importing .bas files Joel Excel Programming 4 March 24th 05 04:14 PM
Importing files Dan E[_2_] Excel Programming 1 July 16th 03 04:53 PM


All times are GMT +1. The time now is 04: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"