Importing information from a odbc source

mikelam

New Member
Joined
Nov 6, 2002
Messages
2
I currently have a macro that runs which collects data from a few workbooks and summarizes it all in one workbook as a report. There is additional information which is obtained from a odbc datasource using Crystal reports and then manually added to the report. I am trying to import the information from within excel as part of the macro. Has anyone attempted this in the past?
 

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

babs

Board Regular
Joined
Oct 30, 2002
Messages
106
Yes, you can do it. Try it with Tools > External Data to start with.

For the commands - try recording macro with all the steps starting from Tools - External Data and then selecting your ODBC connection.

IT works great !!
 

babs

Board Regular
Joined
Oct 30, 2002
Messages
106
Yes, you can do it. Try it with Tools > External Data to start with.

For the commands - try recording macro with all the steps starting from Tools - External Data and then selecting your ODBC connection.

IT works great !!
 

babs

Board Regular
Joined
Oct 30, 2002
Messages
106
Yes, you can do it. Try it with Tools > External Data to start with.

For the commands - try recording macro with all the steps starting from Tools - External Data and then selecting your ODBC connection.

IT works great !!

It should look alike following :

With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=prod;UID=;PWD=;DBQ=PROD;DBA=W;APA=T;EXC=F;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=F;BAM=IfAllSuccessful;MT" _
), Array("S=F;MDI=F;CSR=F;FWC=F;PFC=10;TLO=0;")), Destination:=Range("G9"))
.Sql = sqlname & Chr(13) & "" & Chr(10) & ""
.FieldNames = False
.RefreshStyle = xlDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = False
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = False
End With
 

Watch MrExcel Video

Forum statistics

Threads
1,123,398
Messages
5,601,442
Members
414,450
Latest member
Cassy_sn

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
Top