Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running Macros without opening file.


Hello

I'm not sure to understand but if you want to export datas of a closed
workbook in a text File , you may try


Sub excelVersFichierTexte()
Dim Rs As New ADODB.Recordset
Dim Fichier As String, Feuille As String
Dim xConnect As String, xSql As String

Fichier = "C:\Documents and Settings\michel\WorkBook.xls"
Feuille = "Sheet1"

xConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Fichier &
";" & _
"Extended Properties=Excel 8.0;"

xSql = "SELECT * FROM [" & Feuille & "$];"

Set Rs = New ADODB.Recordset
Rs.Open xSql, xConnect, adOpenForwardOnly, adLockReadOnly, adCmdText

Open "C:\essai.txt" For Output As #1

Do Until Rs.EOF
'vbTab is the separator in this example
'Print #1, Rs.GetString(, 600, ",", vbCrLf, "");
Print #1, Rs.GetString(, 400, vbTab, vbCrLf, "");
Loop
Close #1

End Sub



Regards
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=505783

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 stop Excel from opening all files w/macros & running them BobC Excel Discussion (Misc queries) 4 April 5th 09 08:25 PM
Running Dialog Sheet when opening Excel File Yacov Excel Programming 1 June 16th 05 05:26 PM
Running Macros when opening Excel Chip Pearson Excel Programming 0 April 13th 05 03:09 PM
Running Macros when opening Excel keepITcool Excel Programming 0 April 13th 05 02:15 PM
opening and running macros in an Excel file in a new instance of Excel Malone[_2_] Excel Programming 0 September 30th 03 01:58 AM


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