Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
MindaugasBacius
Partner - Specialist III
Partner - Specialist III

Macros. CopyBitmapToClipboard fails

Hello,

Why could this script fail:

XLApp.Sheets(1).Range("A27").Select

ActiveDocument.GetSheetObject("eur").CopyBitmapToClipboard TRUE

XLApp.Sheets(1).PasteSpecial Format = Bitmap



The error that is given:

Wrong number of arguments or invalid property assignment: 'ActiveDocument.GetSheetObject(...).CopyBitmapToClipboard'



When I change from CopyBitmapToClipboard to CopyTableToClipboard macros executes just fine, only I do get the table not a chart.

Could anybody please help me out?

Thank you!

1 Solution

Accepted Solutions
marcus_sommer

This worked. The main-issue was the missing sheet-reference within excel but there was also a not assigned variable and no store of the excel.

- Marcus

View solution in original post

12 Replies
marcus_sommer

Why do you want to use pastespecial by an image instead of just paste?

- Marcus

MindaugasBacius
Partner - Specialist III
Partner - Specialist III
Author

I do not have any comments on that. I did change it to Paste

Unfortunately I guess that's not the case because while running the code it highlights this line:

ActiveDocument.GetSheetObject("eur").CopyBitmapToClipboard TRUE

marcus_sommer

AFAIK copybitmaptoclipboard hadn't a further parameter TRUE/FALSE because it's only a switch by table-charts and copytabletoclipboard. Beside them you need to ensure that "eur" is really a valid object-id and that this object is currently displayed within qlik - if it's hidden in a container or by a condition or minimized it won't work.

- Marcus

MindaugasBacius
Partner - Specialist III
Partner - Specialist III
Author

The chart is not hidden or minimized, the object ID is valid:

Screenshot_1.jpg

I am also using copytabletoclipboard as well as copybitmaptoclipboard thats why I am using the parameter TRUE/FALSE. By removing it nothing changes the script stops on the same line but without showing any error.

MindaugasBacius
Partner - Specialist III
Partner - Specialist III
Author

Although the script seems to work when leaving everything the same except changing CopyBitmapToClipboard to CopyTableToClipboard.

marcus_sommer

If a qlik macro failed the cursor-position within the macro-editor isn't mandatory by the error and might therefore leading in wrong direction. Put a few msgbox in your code to find the real place where the error happens. If this didn't help please provide an example.

- Marcus

MindaugasBacius
Partner - Specialist III
Partner - Specialist III
Author

ActiveDocument.Sheets(0).Activate
XLApp.Sheets(1).Select
MsgBox "This is fun"
ActiveDocument.GetSheetObject("kg").CopyBitmapToClipboard
'MsgBox "This is fun2"
XLApp.Sheets(1).Range("A27").Select
XLApp.Sheets(1).PasteSpecial Format = Bitmap

With the MsgBox "This is fun" everything works fine. But when I comment it everything stops again. How to understand this? What am I missing?

marcus_sommer

That's strange - maybe something is still processing and not yet finished if you call your routine respectively between the various statements within the routine. To resolve this you could use the following statements:

ActiveDocument.GetApplication.WaitForIdle

rem ** let QV sleep for 1 seconds **

ActiveDocument.GetApplication.Sleep 1000

Beside them I think I wouldn't rather use a selection-statement to the sheet:

XLApp.Sheets(1).Select

else just activating the sheet, select a certain range and than paste your content maybe in this way:

ActiveDocument.Sheets(0).Activate

ActiveDocument.GetSheetObject("kg").CopyBitmapToClipboard

XLApp.Sheets(1).Activate

XLApp.Sheets(1).Range("A27").Select

XLApp.Sheets(1).Paste

- Marcus

MindaugasBacius
Partner - Specialist III
Partner - Specialist III
Author

I am stopped by this issue.

Could you please check the example attached?