Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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,
Could you post your routines?
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
What's exactly the new macro should be doing?
Pasting data into two sheets?
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,