<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Macro is not adding new tab to work sheet in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066678#M641476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you open a new excel file, you will see 3 worksheets (By default). You need to add worksheet, so that you can paste the copied chart into the 4th sheet. You need to add a line like XLDoc.Worksheets.Add().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; I have attached the code in text file. Let me know.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Mar 2016 03:58:10 GMT</pubDate>
    <dc:creator>tamilarasu</dc:creator>
    <dc:date>2016-03-02T03:58:10Z</dc:date>
    <item>
      <title>Macro is not adding new tab to work sheet</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066677#M641475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Macro is generating &lt;SPAN style="font-size: 13.3333px;"&gt;WorkReport.xlsx with Tab1 and Tab2 successfully.&lt;/SPAN&gt;I want to add Tab3,Tab4 to &lt;SPAN style="font-size: 13.3333px;"&gt;WorkReport.xlsx.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I am able to add Tab3 but not Tab4.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Please help me.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Script: &lt;/P&gt;&lt;P&gt;Sub ProductExport&lt;/P&gt;&lt;P&gt;Dim XLApp 'as Excel.Application&lt;/P&gt;&lt;P&gt;Set XLApp = CreateObject("Excel.Application")&lt;/P&gt;&lt;P&gt;Set XLDoc = XLApp.Workbooks.Add&lt;/P&gt;&lt;P&gt;ActiveDocument.GetSheetObject("CH2").CopyTableToClipboard true&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Paste()&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;ActiveDocument.GetSheetObject("CH11").CopyTableToClipboard true&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(4).Paste()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vProductYear = ActiveDocument.Variables("vProductYear")&lt;/P&gt;&lt;P&gt;set vLastYear = ActiveDocument.Variables("vLastYear")&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("year").ToggleSelect vProductYear.GetContent.String&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("year").ToggleSelect vLastYear.GetContent.String&lt;/P&gt;&lt;P&gt;'set vLastYear = ActiveDocument.Variables("vLastYear")&lt;/P&gt;&lt;P&gt;'ActiveDocument.Fields("year").ToggleSelect vLastYear.GetContent.String&lt;/P&gt;&lt;P&gt;ActiveDocument.GetSheetObject("CH1").CopyTableToClipboard true&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Paste()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;ActiveDocument.GetSheetObject("CH22").CopyTableToClipboard true&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(3).Paste()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Rows("1:60000").RowHeight = 12.75&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Columns("A:K").EntireColumn.AutoFit&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Rows("1:60000").RowHeight = 12.75&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Columns("A:AG").EntireColumn.AutoFit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(3).Rows("1:60000").RowHeight = 12.75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(3).Columns("A:AG").EntireColumn.AutoFit&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(4).Rows("1:60000").RowHeight = 12.75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(4).Columns("A:AG").EntireColumn.AutoFit&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set obj = ActiveDocument.GetSheetObject("CH2")&lt;/P&gt;&lt;P&gt;R = obj.GetRowCount&lt;/P&gt;&lt;P&gt;Set WS = XLDoc.worksheets(1)&lt;/P&gt;&lt;P&gt;WS.Range("A1:AG"&amp;amp;R).Borders.LineStyle = 1&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Range("I3:AG"&amp;amp;R).NumberFormat = "#,##0.00"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Set obj = ActiveDocument.GetSheetObject("CH11")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;R = obj.GetRowCount&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;Set WS = XLDoc.worksheets(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;WS.Range("A1:AG"&amp;amp;R).Borders.LineStyle = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(4).Range("I3:AG"&amp;amp;R).NumberFormat = "#,##0.00"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set obj = ActiveDocument.GetSheetObject("CH3")&lt;/P&gt;&lt;P&gt;R = obj.GetRowCount&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Name = "Tab1"&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Name = "Tab2"&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(3).Name = "Tab3"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;XLDoc.Sheets(4).Name = "Tab4"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XLApp.DisplayAlerts = false&lt;/P&gt;&lt;P&gt;Set WS = XLDoc.worksheets(1)&lt;/P&gt;&lt;P&gt;ws.SaveAS "C:\QlikviewOutput\WorkReport.xlsx"&lt;/P&gt;&lt;P&gt;XLApp.DisplayAlerts = true&lt;/P&gt;&lt;P&gt;XLDoc.close&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XLApp.quit&lt;/P&gt;&lt;P&gt;set XLDoc = nothing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End sub &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 03:47:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066677#M641475</guid>
      <dc:creator>qlikviewwizard</dc:creator>
      <dc:date>2016-03-02T03:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro is not adding new tab to work sheet</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066678#M641476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Suren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you open a new excel file, you will see 3 worksheets (By default). You need to add worksheet, so that you can paste the copied chart into the 4th sheet. You need to add a line like XLDoc.Worksheets.Add().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; I have attached the code in text file. Let me know.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 03:58:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066678#M641476</guid>
      <dc:creator>tamilarasu</dc:creator>
      <dc:date>2016-03-02T03:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro is not adding new tab to work sheet</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066679#M641477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As &lt;STRONG style="font-size: 11.7px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;A href="https://community.qlik.com/people/TamilArasu"&gt;TamilArasu&lt;/A&gt;&lt;/STRONG&gt; said there will be default 3 sheets when you create a new file.&amp;nbsp; That is why when you are copying objects in 4th sheet you are getting error.&amp;nbsp; Try adding this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Set XLDoc = XLApp.Workbooks.Add&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;XLDoc.Worksheets.Add()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Hope this helps you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;jagan.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 04:14:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066679#M641477</guid>
      <dc:creator>jagan</dc:creator>
      <dc:date>2016-03-02T04:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro is not adding new tab to work sheet</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066680#M641478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code is not complete and references seems wrong. I just modified your code a bit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub ProductExport&lt;/P&gt;&lt;P&gt;Dim XLApp 'as Excel.Application&lt;/P&gt;&lt;P&gt;Set XLApp = CreateObject("Excel.Application")&lt;/P&gt;&lt;P&gt;Set XLDoc = XLApp.Workbooks.Add&lt;/P&gt;&lt;P&gt;XLDoc.Worksheets.Add()&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;'********************************************************************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;ActiveDocument.GetSheetObject("CH2").CopyTableToClipboard true&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Paste()&lt;/P&gt;&lt;P&gt;ActiveDocument.GetSheetObject("CH1").CopyTableToClipboard true&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Paste()&lt;/P&gt;&lt;P&gt;ActiveDocument.GetSheetObject("CH22").CopyTableToClipboard true&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(3).Paste()&lt;/P&gt;&lt;P&gt;ActiveDocument.GetSheetObject("CH11").CopyTableToClipboard true&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(4).Paste()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;'********************************************************************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;set vProductYear = ActiveDocument.Variables("vProductYear")&lt;/P&gt;&lt;P&gt;set vLastYear = ActiveDocument.Variables("vLastYear")&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("year").ToggleSelect vProductYear.GetContent.String&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("year").ToggleSelect vLastYear.GetContent.String&lt;/P&gt;&lt;P&gt;'set vLastYear = ActiveDocument.Variables("vLastYear")&lt;/P&gt;&lt;P&gt;'ActiveDocument.Fields("year").ToggleSelect vLastYear.GetContent.String&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'********************************************************************************************&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;XLDoc.Sheets(1).Rows("1:60000").RowHeight = 12.75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Columns("A:AG").EntireColumn.AutoFit&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;XLDoc.Sheets(2).Rows("1:60000").RowHeight = 12.75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Columns("A:K").EntireColumn.AutoFit&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;XLDoc.Sheets(3).Rows("1:60000").RowHeight = 12.75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(3).Columns("A:AG").EntireColumn.AutoFit&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;XLDoc.Sheets(4).Rows("1:60000").RowHeight = 12.75&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(4).Columns("A:AG").EntireColumn.AutoFit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-size: 13.3333px;"&gt;'********************************************************************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Set obj = ActiveDocument.GetSheetObject("CH2")&lt;/P&gt;&lt;P&gt;R = obj.GetRowCount&lt;/P&gt;&lt;P&gt;Set WS = XLDoc.worksheets(1)&lt;/P&gt;&lt;P&gt;WS.Range("A1:AG"&amp;amp;R).Borders.LineStyle = 1&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(1).Range("I3:AG"&amp;amp;R).NumberFormat = "#,##0.00"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set obj = ActiveDocument.GetSheetObject("CH1")&lt;/P&gt;&lt;P&gt;R = obj.GetRowCount&lt;/P&gt;&lt;P&gt;Set WS = XLDoc.worksheets(2)&lt;/P&gt;&lt;P&gt;WS.Range("A1:AG"&amp;amp;R).Borders.LineStyle = 1&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Range("I3:AG"&amp;amp;R).NumberFormat = "#,##0.00"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set obj = ActiveDocument.GetSheetObject("CH22")&lt;/P&gt;&lt;P&gt;R = obj.GetRowCount&lt;/P&gt;&lt;P&gt;Set WS = XLDoc.worksheets(3)&lt;/P&gt;&lt;P&gt;WS.Range("A1:AG"&amp;amp;R).Borders.LineStyle = 1&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(3).Range("I3:AG"&amp;amp;R).NumberFormat = "#,##0.00"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set obj = ActiveDocument.GetSheetObject("CH11")&lt;/P&gt;&lt;P&gt;R = obj.GetRowCount&lt;/P&gt;&lt;P&gt;Set WS = XLDoc.worksheets(4)&lt;/P&gt;&lt;P&gt;WS.Range("A1:AG"&amp;amp;R).Borders.LineStyle = 1&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(4).Range("I3:AG"&amp;amp;R).NumberFormat = "#,##0.00"&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px; line-height: 1.5em;"&gt;'********************************************************************************************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;XLDoc.Sheets(1).Name = "Tab1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(2).Name = "Tab2"&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(3).Name = "Tab3"&lt;/P&gt;&lt;P&gt;XLDoc.Sheets(4).Name = "Tab4"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XLApp.DisplayAlerts = false&lt;/P&gt;&lt;P&gt;Set WS = XLDoc.worksheets(1)&lt;/P&gt;&lt;P&gt;ws.SaveAS "C:\QlikviewOutput\WorkReport.xlsx"&lt;/P&gt;&lt;P&gt;XLApp.DisplayAlerts = true&lt;/P&gt;&lt;P&gt;XLDoc.close&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;XLApp.quit&lt;/P&gt;&lt;P&gt;set XLDoc = nothing&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;End sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2016 04:21:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-is-not-adding-new-tab-to-work-sheet/m-p/1066680#M641478</guid>
      <dc:creator>tamilarasu</dc:creator>
      <dc:date>2016-03-02T04:21:03Z</dc:date>
    </item>
  </channel>
</rss>

