Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I need to export via macro a graphic and a straight table, but in different worksheets. I have the following code:
Sub to_excel
Dim wsname
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = TRUE
Set XLDoc = XLApp.Workbooks.Add
wsname = ""
wsname = "Sheet1"
strFileName = "C:\Temp\Example.xls"
ActiveDocument.ClearAll True
ActiveDocument.Fields("Year").Select ("2009")
ActiveDocument.Fields("Month").Select ("Aug")
set obj = ActiveDocument.GetSheetObject("CH585")
obj.CopyBitmapToClipboard
XLDoc.Sheets(wsname).Range("A7").Select
XLDoc.Sheets(wsname).Paste
ActiveDocument.GetApplication.WaitForIdle
'I want this part to be in another worksheet, I tried to add one but it doesn't work
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetSheetObject("CH259").CopyTableToClipboard true
XLDoc.Sheets(wsname).Columns("B").ColumnWidth = 40
XLDoc.Sheets(wsname).Range("A" & 1).Select
XLDoc.Sheets(wsname).Paste
end sub
add this to the script before the first scriptline off 'sheet2'
XLDoc.Sheets(wsname2).activate
add this to the script before the first scriptline off 'sheet2'
XLDoc.Sheets(wsname2).activate
Thank you Dirk! it worked