<?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 Update Pivot data source using VBA code in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/Update-Pivot-data-source-using-VBA-code/m-p/78762#M30751</link>
    <description>I have a requirement to update data source of the pivot in a workbook. Challenge is, I cannot create a macro to update the Workbook is downloaded from one of the data source. I have tried below code and getting 'Exception from HRESULT: 0x80070057 (E_INVALIDARG)' error.

Const xlDatabase as Integer = 1
Const xlR1C1 as Integer = -4150

Dim wb as Object = GetWorkbook(handle, workbook)
Dim ws as Object = wb.Worksheets(worksheet)
Dim newDataSource
Try

newDataSource = wb.PivotCaches.Add (SourceType:=xlDatabase, _
SourceData:= "[Sheet1]" &amp;amp; ws.Range(newLink).Address(ReferenceStyle:=xlR1C1))

Dim pt = ws.PivotTables("PivotTable1")
pt.ChangePivotCache (newDataSource)

success = True

Catch e As Exception
&amp;nbsp;&amp;nbsp; &amp;nbsp;success = False
&amp;nbsp;&amp;nbsp; &amp;nbsp;Message = e.Message
End Try

Anyone tried this scenario? Replies are appreciated. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Mon, 25 Dec 2017 17:00:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-12-25T17:00:00Z</dc:date>
    <item>
      <title>Update Pivot data source using VBA code</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Update-Pivot-data-source-using-VBA-code/m-p/78762#M30751</link>
      <description>I have a requirement to update data source of the pivot in a workbook. Challenge is, I cannot create a macro to update the Workbook is downloaded from one of the data source. I have tried below code and getting 'Exception from HRESULT: 0x80070057 (E_INVALIDARG)' error.

Const xlDatabase as Integer = 1
Const xlR1C1 as Integer = -4150

Dim wb as Object = GetWorkbook(handle, workbook)
Dim ws as Object = wb.Worksheets(worksheet)
Dim newDataSource
Try

newDataSource = wb.PivotCaches.Add (SourceType:=xlDatabase, _
SourceData:= "[Sheet1]" &amp;amp; ws.Range(newLink).Address(ReferenceStyle:=xlR1C1))

Dim pt = ws.PivotTables("PivotTable1")
pt.ChangePivotCache (newDataSource)

success = True

Catch e As Exception
&amp;nbsp;&amp;nbsp; &amp;nbsp;success = False
&amp;nbsp;&amp;nbsp; &amp;nbsp;Message = e.Message
End Try

Anyone tried this scenario? Replies are appreciated. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 25 Dec 2017 17:00:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Update-Pivot-data-source-using-VBA-code/m-p/78762#M30751</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-12-25T17:00:00Z</dc:date>
    </item>
    <item>
      <title>I also faced the similar…</title>
      <link>https://community.blueprism.com/t5/Product-Forum/Update-Pivot-data-source-using-VBA-code/m-p/78763#M30752</link>
      <description>I also faced the similar issue, Anyone have a solution</description>
      <pubDate>Fri, 04 May 2018 00:12:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/Update-Pivot-data-source-using-VBA-code/m-p/78763#M30752</guid>
      <dc:creator>EswarPalivela</dc:creator>
      <dc:date>2018-05-04T00:12:00Z</dc:date>
    </item>
  </channel>
</rss>

