I have an excel macro that all it does is export a table into excel, turns the field names to 90 degrees, copies the chart as a picture and exits. This macro will run several times in a given session. The problem is that on the second run it dies on "with Rows("1:1") The error is "Method 'Rows' of object '_Global' failed. I thought I reset everything but I guess not. I have also tried making the application not visable. It will run but then i don't get my picture copied.
Code:
Set xlapp = CreateObject("Excel.Application")
xlapp.Application.Visible = True
Set xlwkb = xlapp.Workbooks.Open(sfile)
With xlwkb
'Rows("1:1").Select
With Rows("1:1")
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 90
.AddIndent = False
.ShrinkToFit = True
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.EntireColumn.AutoFit
'Range("A1:AM4").Select
Range("A1:AM4").CopyPicture
End With
xlwkb.Saved = True
xlwkb.Close
xlapp.Quit
Set xlwkb = Nothing
Set xlapp = Nothing