Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-10-2011, 03:44 AM
Catalin.B Catalin.B is offline Macro to loop in subfolders, change links, export xml data Windows Vista Macro to loop in subfolders, change links, export xml data Office 2007
Expert
Macro to loop in subfolders, change links, export xml data
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default Macro to loop in subfolders, change links, export xml data

Hello,
Here i come again with another interesting challenge: to export data from a big number of subfolders , ALMOST each subfolder containing two source excel workbooks, filled with data, and export that data, for every client, in an xml file, for use in another PDF forms. Manually, i change the links in this collector to the next client, and after that, save and export data to xml.
The only problem is there are hundreds of subfolders (clients)
So i began working on this macro, but cannot find yet a way to make the macro search for new link path for the 2 excel files connections in next subfolder . Can you point me to the best way to do this?
Thanks in advance,
Catalin B.

Sub Macrocomandă2()
' I need for this workbook, which is linked to 2 other workbooks, and has atached an xsd schema, to loop through subfolders, changing links, saving and
' exporting data to xml file, in order to import this data to PDF forms



ChDir "E:\Sesiunea 4 - 141-iunie 2011\Acatincai Luminita"
' This, and all other target subfolders is a subfolder of "E:\Sesiunea 4 - 141-iunie 2011\"
' In almost every subfolder, there are 2 workbooks, one with text "plan afaceri" in the file name,
' the other with text "date personale" in the file name


ActiveWorkbook.ChangeLink Name:= _
"E:\Sesiunea 4 - 141-iunie 2011\Acatincai Luminita\141-plan afaceri Acatincăi.xls" _
, NewName:= _
"E:\Sesiunea 4 - 141-iunie 2011\Acatincai Luminita\141-plan afaceri Acatincăi.xls" _
, Type:=xlExcelLinks


' this the old path for the first linked workbook, with text "plan afaceri" in the filename
' I need to set the old link name to the existing link path,
' and the new path name to the excel files in the next subfolder, which contains in the
' file name the text "plan afaceri" for a set of links,
' and "date personale" for the second linked workbook
' If in the next subfolder in range one of the excel files containing in the filename
' "plan afaceri" or "date personale" is missing, the macro should change the links to files in the next subfolder



' this the old path for the second linked workbook, with text "date personale" in the filename
ActiveWorkbook.ChangeLink Name:= _
"E:\Sesiunea 4 - 141-iunie 2011\Acatincai Luminita\Date personale, chestionar, acte necesare 141- Acatincai Luminita.xls" _
, NewName:= _
"E:\Sesiunea 4 - 141-iunie 2011\Acatincai Luminita\Date personale, chestionar, acte necesare 141- Acatincai Luminita.xls" _
, Type:=xlExcelLinks

'After changing the links for "plan afaceri" and "date personale", all i need
'is to execute the folowing commands after every change of links



Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.DisplayAlerts = True
ActiveWorkbook.XmlMaps("pdf_121_Asociere").Export URL:= _
"C:\Users\Catalin\Desktop\Cereri finantare\ " & Sheets("Foaie1").Range("b3").Value & "" _
, Overwrite:=True
' Obviously, in B3 there is the client name with &".xml" attached
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Made a mistake with a macro change lance_kidd Word 0 02-09-2011 06:36 PM
Accessing Outlook Contacts in Subfolders jill5545 Outlook 1 11-17-2010 04:01 PM
Create a Custome Form and export data to Access ashleybyrdnc Office 0 03-05-2010 09:41 AM
Macro to export document sections to individual txt files? MJMR999 Excel Programming 0 02-18-2010 12:49 PM
Subfolders in Inbox and Sent Items stevie Outlook 0 09-08-2009 02:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft