Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Qlikview macro export / copy an table data to open excel file

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

1 Solution

Accepted Solutions
Not applicable
Author

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

View solution in original post

8 Replies
sinanozdemir
Specialist III
Specialist III

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.

Not applicable
Author

HI

thanks but this is not working!!

It's copying to excel

LB183 and not the data ??

I don't know why?

Not applicable
Author

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

sasikanth
Master
Master

please check the following link

Useful Qlikview Macros

Not applicable
Author

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

Not applicable
Author

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

Not applicable
Author

Do


ActiveDocument.GetSheetObject("LB183").CopyTableToClipboard true

Not applicable
Author

THANKS A LOT REALLY

Now it's workign fine