Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error 1004 + my Pivot Tables

While using VBA script to refresh Excel Pivot Tables from Access I am getting
error
message 1004 if the command button is pressed several times. I understand
that this is because the local variables are holding a reference to the Pivot
Tables. (I have referred to "Excel automation fails second time code runs -
http://support.microsoft.com/kb/178510/en-us")

<----Quoting /kb/178510/

Private Sub Command1_Click()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets("Sheet1")
xlSheet.Range(Cells(1, 1), Cells(10, 2)).Value = "Hello"
xlBook.Saved = True
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub

*------Quoting /kb/178510/

8. Stop the project and change the following line:

xlSheet.Range(Cells(1,1),Cells(10,2)).Value = "Hello"

to: xlSheet.Range(xlSheet.Cells(1,1),xlSheet.Cells(10, 2)).Value = "Hello"
----

The example there uses a worksheet that is built from scratch. I am having
trouble
getting the right syntax for an existing Pivot Table within an existing
Worksheet.

Thanks in advance.
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
pivot table error 1004 Richard Excel Programming 0 October 24th 06 01:25 PM
Pivot macros error 1004 ymeyaw[_7_] Excel Programming 0 June 27th 06 10:29 AM
Pivot Table Run Time Error 1004 Dale Excel Programming 0 May 3rd 06 04:46 PM
pivot table Commandtext causes runtime error 1004 in excel 2000 Therezee Excel Programming 0 April 12th 06 04:39 AM
Pivot Table Error 1004 Terri[_5_] Excel Programming 1 May 26th 05 10:39 AM


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

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

About Us

"It's about Microsoft Excel"