craig80

Board Regular
Joined
May 18, 2010
Messages
51
Hello All,

I have created a data cube which is created on batch every morning. Ideally this will need ot be a DB, but in the mean time I need to query this data set and drop it into a template of other reports.

I have created a query in MS Query, which I reference in VBA to extract to a point in my report. I have run this report succefully a few times. But i can't do this consitantly. It trips out at the line i have highlighted?

Any help would be a huge help.

Many Thanks

Craig

Sub Add_and_remove_connection()
'
' Add_and_remove_connection
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\Documents and Settings\Craig\Desktop\Reporting Suite\MS Query Example.dqy", _
Destination:=Range("A1"))
.Name = "Cube Data WorkTypeRemoved"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
'.RefreshStyle = xlInsertDeleteCells
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False


End With
End Sub
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top