Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jam22171
 
Posts: n/a
Default Changing OLE DB connection

I'm trying to create a macro that will automatically Edit OLE DB Query each
month. The closest help I got was the following:
tSource="C:\Mar05\File05.xls"
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & tSource & ";" & _
"Extended Properties=Excel 8.0;"
.Open
End With

Not sure of the Open but what I'd like to see the new source file when I
check on the Edit OLE DB Query screen the next time.

Thanks in advance.
  #2   Report Post  
 
Posts: n/a
Default



Jam22171 wrote:
I'm trying to create a macro that will automatically Edit OLE DB Query each
month. The closest help I got was the following:
tSource="C:\Mar05\File05.xls"


Maybe one of

tSource="C:\" & Format$(Date, "mmmyy") & "\File05.xls"
tSource="C:\" & Format$(Date, "mmmyy") & "\File" & Format$(Date, "yy")
& ".xls"
tSource="C:\" & Format$(Date, "mmmyy") & "\File" & Format$(Date, "mm")
& ".xls"

  #3   Report Post  
Jam22171
 
Posts: n/a
Default

Thanks, peregenem. What I actually need is how to implement the change of
connection. My macro coded as follows:

Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
tSource="C:\Mar05\File05.xls" 'new
connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & tSource & ";" & _
"Extended Properties=Excel 8.0;" 'to replace old source
file with new
.Open
End With

I'm not sure if this is the right approach because I can't make it work.
Thanks



" wrote:



Jam22171 wrote:
I'm trying to create a macro that will automatically Edit OLE DB Query each
month. The closest help I got was the following:
tSource="C:\Mar05\File05.xls"


Maybe one of

tSource="C:\" & Format$(Date, "mmmyy") & "\File05.xls"
tSource="C:\" & Format$(Date, "mmmyy") & "\File" & Format$(Date, "yy")
& ".xls"
tSource="C:\" & Format$(Date, "mmmyy") & "\File" & Format$(Date, "mm")
& ".xls"


  #4   Report Post  
 
Posts: n/a
Default



Jam22171 wrote:
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & tSource & ";" & _
"Extended Properties=Excel 8.0;" 'to replace old source

I'm not sure if this is the right approach because I can't make it work.


Try putting the Excel 8.0 in single quotes

..Provider = "Microsoft.Jet.OLEDB.4.0"
..ConnectionString = "Data Source=" & tSource & ";" & _
"Extended Properties='Excel 8.0'"

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 save an OLAP connection to distribute with an Excel sheet JohnA Excel Discussion (Misc queries) 0 May 19th 05 03:35 PM
Changing the format of an Excel output file made by Microsoft Access Amir Excel Discussion (Misc queries) 2 May 1st 05 12:57 AM
How do I stop excel automatically changing my date to 2005? zoemcb Excel Discussion (Misc queries) 6 April 30th 05 02:39 AM
changing page break in an excel file ibs81 New Users to Excel 1 April 14th 05 07:03 PM
Changing Server on a Microsoft Query Grantley Excel Discussion (Misc queries) 0 March 31st 05 10:33 PM


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