Macro to export based on a column's value
For Every possible values seperate excel file will be generated.
Sub Export1
ActiveDocument.ClearAll false
pathcorp="F:\TEST\"
set corp = ActiveDocument.GetSheetObject("CH02")
corp.ExportBiff pathcorp & "TEST.xls"
ActiveDocument.Fields("REGION").Clear
set val=ActiveDocument.Fields("REGION").GetPossibleValues
set XLApp = CreateObject("EXCEL.application")
XLApp.Visible = FALSE
set XLDoc = XLApp.Workbooks.Add
for i=0 to val.Count-1
set MyTable = ActiveDocument.GetSheetObject("CH02")
path="F:\TEST\"
ActiveDocument.Fields("REGION").Select val.Item(i).Text
MyTable.ExportBiff path & val.Item(i).Text &".xls"
next
Set XLApp = Nothing
Set Table = Nothing
'Msgbox "Exported Sucessfully"
end sub
Click here to download script as txt file
For Every possible values seperate excel file will be generated.
Sub Export1
ActiveDocument.ClearAll false
pathcorp="F:\TEST\"
set corp = ActiveDocument.GetSheetObject("CH02")
corp.ExportBiff pathcorp & "TEST.xls"
ActiveDocument.Fields("REGION").Clear
set val=ActiveDocument.Fields("REGION").GetPossibleValues
set XLApp = CreateObject("EXCEL.application")
XLApp.Visible = FALSE
set XLDoc = XLApp.Workbooks.Add
for i=0 to val.Count-1
set MyTable = ActiveDocument.GetSheetObject("CH02")
path="F:\TEST\"
ActiveDocument.Fields("REGION").Select val.Item(i).Text
MyTable.ExportBiff path & val.Item(i).Text &".xls"
next
Set XLApp = Nothing
Set Table = Nothing
'Msgbox "Exported Sucessfully"
end sub
Click here to download script as txt file
how can i call this SUB from Script Editor?
ReplyDeleteWe use exportbiff to export to a excel file. How about if i want to export to a txt file?
ReplyDeleteMyTable..Export "D:\Qlikview\CSVReports\Test.csv", ", "
ReplyDeleteIs it possible to export multiple charts in single Excel using ExportBiff (which means not by using CreateObject("Excel.Application"))
ReplyDeleteYou can use copy objects to excel sheet().however to a new sheet in the same excel.
DeleteCan you Please elaborate(if possible with sample code/syntax)?
DeleteThank you.
It doesnot work with Publisher. Any idea regarding using a macro fucntion and then calling the actual macro file to call which will have a code for export an excel of any chart ?
ReplyDeleteManage your own destiny - TITNIA GARLING TONS - Titanium
ReplyDeleteWith the power of thorium gallium gallium gallium gallium gallium gallium gallium gallium gallium gallium w88 gallium gallium titanium nipple jewelry gallium titanium 200 welder gallium 2013 ford focus titanium hatchback gallium titanium wood stoves gallium gallium gallium gallium gallium