1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Sub ProcessFiles()
Dim Filename
Dim Pathname
Dim wb
Pathname = ActiveWorkbook.Path & "\c:\toto\"
Filename = Dir(Pathname & "*.xls")
Do While Filename <> ""
Set wb = Workbooks.Open(Pathname & Filename)
DoWork wb
wb.Close SaveChanges=True
Filename = Dir()
Loop
End Sub
Sub DoWork(wb)
With wb
Range("a16").Select
Selection.CurrentRegion.Select
myrange = Selection.Address
mysheetname = ActiveSheet.Name
ActiveSheet.ChartObjects.Add(300, 250, 600, 400).Select
Application.CutCopyMode = False
ActiveChart.ChartWizard _
Source=Sheets(mysheetname).Range(myrange), _
Gallery=xlColumnStacked, Format=4, PlotBy=xlColumns, _
CategoryLabels=1, SeriesLabels=1, HasLegend=1, _
Title="", CategoryTitle="", _
ValueTitle="", ExtraTitle=""
End With
End Sub |
Partager