Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I am trying to export / copy data from qv to excel.
the problem that it's that the excel file is already open I don't want to copy the data to a new excel file.
this macro copy the image - I need to copy the data as well
Sub export
set XLApp = CreateObject("Excel.Application")
set XLDOC = XLApp.Workbooks.Open ("C:\Blank 360.xlsm")
XLApp.Visible = True
xlApp.DisplayAlerts=false
Set wbTarget = xlApp.Workbooks(1)
wbTarget.SaveAs ("C:\Blank 360.xlsm")
Const XLPasteValues = -4163
ActiveDocument.ClearCache
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetSheetObject("LB183").Restore
ActiveDocument.GetSheetObject("LB183").CopyBitmapToClipboard 'Copy the charts
set XLSheet = XLDOC.Worksheets("QV") ' again this could be any worksheet name in your 'Data.xls'
XLSheet.Paste XLSheet.Range("A1")
wbTarget.Save
wbTarget.close
xlApp.DisplayAlerts=true
End Sub
thanks
Hi,
May following simple code will help. Change Sheet IDs and Sheet name as per........
sub Export_excel
set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
set XLDoc = XLApp.Workbooks.Open("C:\Blank 360.xlsm")
set PHARMA = XLDoc.Worksheets("Sheet1")
ActiveDocument.GetSheetObject("LB183").CopyTableToClipboard true
XLDoc.Sheets("Sheet1").Activate
PHARMA.Paste PHARMA.Range("A1")
Set PHARMA = XLDoc.Worksheets("Sheet2")
ActiveDocument.GetSheetObject("LB184").CopyTableToClipboard true
XLDoc.Sheets("Sheet2").Activate
PHARMA.Paste PHARMA.Range("A1")
.
.
.
.
XLDoc.Close SaveChanges = true
XLApp.Workbooks("Blank 360.xlsm").Close
XLApp.Quit
end sub
Regards,
Devanand
Hi,
Change the line to this:
Sub export
set XLApp = CreateObject("Excel.Application")
set XLDOC = XLApp.Workbooks.Open ("C:\Blank 360.xlsm")
XLApp.Visible = True
xlApp.DisplayAlerts=false
Set wbTarget = xlApp.Workbooks(1)
wbTarget.SaveAs ("C:\Blank 360.xlsm")
Const XLPasteValues = -4163
ActiveDocument.ClearCache
ActiveDocument.GetApplication.WaitForIdle
ActiveDocument.GetSheetObject("LB183").Restore
ActiveDocument.GetSheetObject("LB183").CopyValuesToClipboard 'Copy the charts
set XLSheet = XLDOC.Worksheets("QV") ' again this could be any worksheet name in your 'Data.xls'
XLSheet.Paste XLSheet.Range("A1")
wbTarget.Save
wbTarget.close
xlApp.DisplayAlerts=true
End Sub
Hope this helps.
HI
thanks but this is not working!!
It's copying to excel
LB183 and not the data ??
I don't know why?
Hi
I tried on a new QV and just trying to copy data and not the image
I just understand that the macro copy the last value that I copy using CTRL C
what ever where!!!
So right now it'snot working
please check the following link
THanks But I am in the same situation, I don't understand how to copy data to existing file.
all the macro I I found creating a new excel.
I would like as the image open the excel file, copy image and "what is missing for me" data
I am trying to search over the net but up to now, I didn't found a solution. I am STUCK
THanks a lot
Hi,
May following simple code will help. Change Sheet IDs and Sheet name as per........
sub Export_excel
set XLApp = CreateObject("Excel.Application")
XLApp.Visible = true
set XLDoc = XLApp.Workbooks.Open("C:\Blank 360.xlsm")
set PHARMA = XLDoc.Worksheets("Sheet1")
ActiveDocument.GetSheetObject("LB183").CopyTableToClipboard true
XLDoc.Sheets("Sheet1").Activate
PHARMA.Paste PHARMA.Range("A1")
Set PHARMA = XLDoc.Worksheets("Sheet2")
ActiveDocument.GetSheetObject("LB184").CopyTableToClipboard true
XLDoc.Sheets("Sheet2").Activate
PHARMA.Paste PHARMA.Range("A1")
.
.
.
.
XLDoc.Close SaveChanges = true
XLApp.Workbooks("Blank 360.xlsm").Close
XLApp.Quit
end sub
Regards,
Devanand
Do
ActiveDocument.GetSheetObject("LB183").CopyTableToClipboard true
THANKS A LOT REALLY
Now it's workign fine