Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

macro for copy and paste in excel

Hi,

i have pivot table in my project, when i click on the excel it exporting in excel it is working fine. But i want to copy the full table and paste it into new excel,this i will do by manually.Instead of doing this manually is there any possible to write a macro and creating one button,when i click on this button the report should be copy and paste in new excel.

can anyone know the macro for this please share....

regards,

baru

5 Replies
Gysbert_Wassenaar

Try this code from rebeccad:

sub Export

set XLApp = CreateObject("Excel.Application")

XLApp.Visible = true 'you can make it false, if you want to make it in the background

set XLDoc = XLApp.Workbooks.Add

XLDoc.Sheets(1).name = "Export"

set XLSheet = XLDoc.Worksheets(1)

set MyTable = ActiveDocument.GetSheetObject("CH01") 'Change CH01 to the object you want to export to Excel (Object Properties > General tab > far right)

set XLSheet = XLDoc.Worksheets(1) 'Select sheet where data should be pasted

Mytable.CopyTableToClipboard true 'Copy data to Clipboard

XLSheet.Paste XLSheet.Range("A1") 'Paste data starting at A1

End Sub


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Gysbert,

Thanks for your reply,

it is not working,when i click on the button macro is opening,can you please explain me little bit more...

Not applicable
Author

Hi Gysbert,

Thanks for your reply,

it is not working,when i click on the button macro is opening,can you please explain me little bit more...

Gysbert_Wassenaar

Set Requested Module Security to System Access and Current Local Security to Allow System Access. This is need to allow the macro to create an Excel instance.


talk is cheap, supply exceeds demand
Not applicable
Author

hi,

I enabled this two options,but still same error.