Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Can't set CommandText if pivot table copied

I have a pivot table on sheet1 that I can change the query parameters
using the PivotCache.CommandText property. But if I copy that pivot
table onto a new worksheet, or copy the entire worksheet, I can no
longer set the PivotCache.CommandText for either pivot tables. If I
delete the copied worksheet, I can set the CommandText again on the
original pivot table.

Does anyone have any solutions?

Thanks for looking.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Can't set CommandText if pivot table copied

If it's an ODBC connection, you can temporarily change it to OLEDB, then
change the command text. For example:

'==============
Sub SetCmdText()
Dim pc As PivotCache
Dim strConn As String
Dim strConn2 As String
Set pc = ActiveWorkbook.PivotCaches(1)
strConn = pc.Connection
strConn2 = Replace(strConn, "ODBC", "OLEDB")

pc.Connection = strConn2
pc.CommandText _
= ActiveSheet.Range("rngCmdTxt2").Value
pc.Connection = strConn
ActiveWorkbook.RefreshAll

End Sub
'=================

steveh wrote:
I have a pivot table on sheet1 that I can change the query parameters
using the PivotCache.CommandText property. But if I copy that pivot
table onto a new worksheet, or copy the entire worksheet, I can no
longer set the PivotCache.CommandText for either pivot tables. If I
delete the copied worksheet, I can set the CommandText again on the
original pivot table.

Does anyone have any solutions?

Thanks for looking.



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Can't set CommandText if pivot table copied

Ron Coderre has a pivot table add-in that lets you view and edit a pivot
table's connection string and command text, in Excel 2002 or Excel 2003:

http://www.contextures.com/xlPivotPlay01.html

Maybe that will help.

steveh wrote:
I must be doing something wrong because that didn't work for me.


Debra Dalgleish wrote:

If it's an ODBC connection, you can temporarily change it to OLEDB,
then change the command text. For example:

'==============
Sub SetCmdText()
Dim pc As PivotCache
Dim strConn As String
Dim strConn2 As String
Set pc = ActiveWorkbook.PivotCaches(1)
strConn = pc.Connection
strConn2 = Replace(strConn, "ODBC", "OLEDB")

pc.Connection = strConn2
pc.CommandText _
= ActiveSheet.Range("rngCmdTxt2").Value
pc.Connection = strConn
ActiveWorkbook.RefreshAll

End Sub
'=================

steveh wrote:

I have a pivot table on sheet1 that I can change the query parameters
using the PivotCache.CommandText property. But if I copy that pivot
table onto a new worksheet, or copy the entire worksheet, I can no
longer set the PivotCache.CommandText for either pivot tables. If I
delete the copied worksheet, I can set the CommandText again on the
original pivot table.

Does anyone have any solutions?

Thanks for looking.






--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Stupid CommandText Problem El Pablo[_2_] Excel Programming 0 July 4th 06 08:30 PM
CommandText Simon Shaw Excel Programming 7 July 4th 06 07:05 PM
pivot table Commandtext causes runtime error 1004 in excel 2000 Therezee Excel Programming 0 April 12th 06 04:39 AM
CommandText Property Dick Kusleika[_3_] Excel Programming 0 October 17th 03 11:04 PM
change commandtext in pivotcaches patrick Excel Programming 3 September 2nd 03 03:06 PM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"