Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic Macro

Hi,

I have two different subroutine A and B  which runs separately as well as together.  A and B creates a workbook and adds a worksheet to copy past the objects from QV from different tabs.

As per the requirement when both subroutines execute together data should be pasted in on workbook with two sheets for subroutine A and B.

Any help would be appreciated.

Let me know in case any details are required.

Regards,

4 Replies
robert_mika
Master III
Master III

Could you post your routines?

Not applicable
Author

Hi Robert,

Thank you for the response below is the routines.

Let me know in case any details required.

sub A

Set XLapp = CreateObject("Excel.Application")

XLapp.Visible = True

Set XLdoc = XLapp.Workbooks.Add

Set XLsheet = XLdoc.Worksheets.Add

'Copying The Caption

'******************************** Overall ******************************

Set tableToExport = ActiveDocument.GetSheetObject("CH_HL_A1")

chartCaption = tableToExport.GetCaption.Name.v                        

XLsheet.Range("A1") = chartCaption

XLSheet.Range("A1:E1").Merge

XLsheet.Range("A2").Select

Set obj = ActiveDocument.GetSheetObject("CH_HL_A1")

obj.CopyTableToClipboard True

XLsheet.Paste

end sub

sub B

Set XLapp = CreateObject("Excel.Application")

XLapp.Visible = True

Set XLdoc = XLapp.Workbooks.Add

Set XLsheet = XLdoc.Worksheets.Add

'Copying The Caption

'******************************** Overall ******************************

Set tableToExport = ActiveDocument.GetSheetObject("CH_CHL_A1")

chartCaption = tableToExport.GetCaption.Name.v                        

XLsheet.Range("A1") = chartCaption

XLSheet.Range("A1:E1").Merge

XLsheet.Range("A2").Select

Set obj = ActiveDocument.GetSheetObject("CH_CHL_A1")

obj.CopyTableToClipboard True

XLsheet.Paste

end sub

robert_mika
Master III
Master III

What's exactly the new macro should be doing?

Pasting data into two sheets?

Not applicable
Author

Hi Robert,

Apologies for delay in response.

Yes it should paste the data into two sheets as I have A and B routines which works exactly same but when I call them together

Call A

Call B

The output should be pasted in a single / same workbook and on different worksheets.

Regards,