+ Reply to Thread
Results 1 to 3 of 3

Running Macros without opening file.

  1. #1

    Running Macros without opening file.

    I have a big Excel file and a macro which processes this Excel file and
    spits out a text file. Is it possible to run this macro without opening
    the Excel file? Opening a 100MB excel file takes time and doing it 100
    times over is not fun...


  2. #2
    Monish
    Guest

    RE: Running Macros without opening file.

    If you save a copy of your Excel file under a standard file name, say
    "LargeFile.xls" then you could set up a macro to find and run "LargeFile.xls"
    to output a saved text file.

    You would save this macro under All Open Workbooks, then open Excel without
    opening your large file in order to find and run your macro.

    HTH

    "[email protected]" wrote:

    > I have a big Excel file and a macro which processes this Excel file and
    > spits out a text file. Is it possible to run this macro without opening
    > the Excel file? Opening a 100MB excel file takes time and doing it 100
    > times over is not fun...
    >
    >


  3. #3
    Forum Contributor
    Join Date
    12-11-2004
    MS-Off Ver
    2007
    Posts
    137
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1