Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default new workbook with new Query

Hi,
I am working on a macro that I'd like to insert a query table into a new
workboook.

To get the code for the create query part, I used the macro recorder.

Workbooks.Add
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=pma;UID=;;SERVER=pma;", Destination:=Range("A1"))
.CommandText = Array( _
"Select * from acct_dim")
.Name = "Query from pma"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

Without doing anything I just ran the macro again to test it and it faults at
.Refresh BackgroundQuery:=False with
RunTime '1004' Application-defined or object-defined error

Any ideas what could be causing the problem?

Thanks!
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
Query worksheets in same workbook [email protected] Excel Worksheet Functions 1 May 1st 07 10:58 PM
Need to Query data on the same Workbook JT Excel Programming 0 October 8th 06 12:46 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 1 November 29th 05 01:44 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 0 November 28th 05 06:37 PM
workbook open query labrev Excel Programming 2 October 12th 05 09:56 PM


All times are GMT +1. The time now is 04:12 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"