Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Change Pivot Table's query

Hi,

I'm trying to change the sql statement of a Pivot Table through VB6.
But, on the following line,
pt.PivotCache.sql =
StringToArray(ExcelWorkbook.Application.Substitute (pt.PivotCache.sql,
OldSQL, NewSQL))

I get the following error:
1004 - Application-defined or object-defined error

I've also tried with:
pt.PivotCache.CommandText =
StringToArray(ExcelWorkbook.Application.Substitute (pt.PivotCache.Command
Text, OldSQL, NewSQL))

but I get the same error. Any ideias?




*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Change Pivot Table's query

I have discovered, after spending several hours on this topic myself, that a
CommandText or SQL value whose length is between 242 characters and 257
characters (inclusive) will throw this error every time. Don't ask me why.
I haven't a clue.

I discovered this by starting with a SQL string that caused this problem for
me and adding comment text to the end of it or subtracting superfluous spaces
from it until it ceased causing an error.

It is important to note that I can not duplicate this problem manually in
Excel nor by using Excel VBA to edit the CommandText from the workbook
itself. It seems to only occur when controlling a Pivot Table (or possibly
other query-related Excel objects) through Office Automation.

My suggestion to you would be to modify your SQL string to include a healthy
chunk of comments at the end to avoid this issue.

From everything that I can tell, converting the string to an array does not
solve a thing.

Andrew D. Wachs

"bocachai" wrote:

Hi,

I'm trying to change the sql statement of a Pivot Table through VB6.
But, on the following line,
pt.PivotCache.sql =
StringToArray(ExcelWorkbook.Application.Substitute (pt.PivotCache.sql,
OldSQL, NewSQL))

I get the following error:
1004 - Application-defined or object-defined error

I've also tried with:
pt.PivotCache.CommandText =
StringToArray(ExcelWorkbook.Application.Substitute (pt.PivotCache.Command
Text, OldSQL, NewSQL))

but I get the same error. Any ideias?




*** Sent via Developersdex http://www.developersdex.com ***

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
how do I extend an existing pivot table's range Chris Smith Excel Discussion (Misc queries) 4 June 15th 07 06:02 PM
Identifying Pivot Table's Field Juan Sanchez Excel Programming 2 October 5th 04 03:06 PM
Imitating Pivot table's context awareness R Avery Excel Programming 3 September 17th 04 05:19 PM
Accessing Pivot Table's Data in VBA spjoseph0511 Excel Programming 3 November 14th 03 03:15 AM
Accessing Pivot Table's Data spjoseph0511[_2_] Excel Programming 1 November 13th 03 07:36 PM


All times are GMT +1. The time now is 01:43 AM.

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"