+ Reply to Thread
Results 1 to 6 of 6

Open a file do a macro ( made) and open next succesive file

  1. #1
    SVTman74
    Guest

    Open a file do a macro ( made) and open next succesive file

    Open a file do a macro ( made) and open next succesive file

    File name yyyy-mm-ddxxxx.csv <--- the date is the creation date.
    can I have excel run the macro to auto matically open first file in dir run
    its parse and save ( this is done) THEN open the next file and continue?



  2. #2
    Bernie Deitrick
    Guest

    Re: Open a file do a macro ( made) and open next succesive file

    Here's the general idea:

    Sub OpenUserSelectedFiles()
    Dim i As Integer
    Dim filearray As Variant

    filearray = Application.GetOpenFilename( _
    Title:="Select the files to process", MultiSelect:=True)
    If IsArray(filearray) Then
    For i = LBound(filearray) To UBound(filearray)
    Workbooks.Open filearray(i)
    'Call your macro here
    ActiveWorkbook.Close False
    Next i
    Else:
    MsgBox "You clicked cancel"
    End If
    End Sub

    HTH,
    Bernie
    MS Excel MVP


    "SVTman74" <[email protected]> wrote in message
    news:[email protected]...
    > Open a file do a macro ( made) and open next succesive file
    >
    > File name yyyy-mm-ddxxxx.csv <--- the date is the creation date.
    > can I have excel run the macro to auto matically open first file in dir run
    > its parse and save ( this is done) THEN open the next file and continue?
    >
    >




  3. #3
    David
    Guest

    Re: Open a file do a macro ( made) and open next succesive file

    Do you know anyway when using the Application.GetOpenFilename function to use
    a specific filename that is a defined string?
    Example: SName is BP-Sarasota.xls
    Tried fname=Application.GetOpenFilename(SName) but no joy.
    Any ideas?

    David

    "Bernie Deitrick" wrote:

    > Here's the general idea:
    >
    > Sub OpenUserSelectedFiles()
    > Dim i As Integer
    > Dim filearray As Variant
    >
    > filearray = Application.GetOpenFilename( _
    > Title:="Select the files to process", MultiSelect:=True)
    > If IsArray(filearray) Then
    > For i = LBound(filearray) To UBound(filearray)
    > Workbooks.Open filearray(i)
    > 'Call your macro here
    > ActiveWorkbook.Close False
    > Next i
    > Else:
    > MsgBox "You clicked cancel"
    > End If
    > End Sub
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    >
    > "SVTman74" <[email protected]> wrote in message
    > news:[email protected]...
    > > Open a file do a macro ( made) and open next succesive file
    > >
    > > File name yyyy-mm-ddxxxx.csv <--- the date is the creation date.
    > > can I have excel run the macro to auto matically open first file in dir run
    > > its parse and save ( this is done) THEN open the next file and continue?
    > >
    > >

    >
    >
    >


  4. #4
    Lucas Swanson
    Guest

    Re: Open a file do a macro ( made) and open next succesive file

    That is not the way GetOpenFilename works. GetOpenFilename launches a dialog
    box asking the user to select which files should be opened.

    "David" wrote:

    > Do you know anyway when using the Application.GetOpenFilename function to use
    > a specific filename that is a defined string?
    > Example: SName is BP-Sarasota.xls
    > Tried fname=Application.GetOpenFilename(SName) but no joy.
    > Any ideas?
    >
    > David
    >
    > "Bernie Deitrick" wrote:
    >
    > > Here's the general idea:
    > >
    > > Sub OpenUserSelectedFiles()
    > > Dim i As Integer
    > > Dim filearray As Variant
    > >
    > > filearray = Application.GetOpenFilename( _
    > > Title:="Select the files to process", MultiSelect:=True)
    > > If IsArray(filearray) Then
    > > For i = LBound(filearray) To UBound(filearray)
    > > Workbooks.Open filearray(i)
    > > 'Call your macro here
    > > ActiveWorkbook.Close False
    > > Next i
    > > Else:
    > > MsgBox "You clicked cancel"
    > > End If
    > > End Sub
    > >
    > > HTH,
    > > Bernie
    > > MS Excel MVP
    > >
    > >
    > > "SVTman74" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Open a file do a macro ( made) and open next succesive file
    > > >
    > > > File name yyyy-mm-ddxxxx.csv <--- the date is the creation date.
    > > > can I have excel run the macro to auto matically open first file in dir run
    > > > its parse and save ( this is done) THEN open the next file and continue?
    > > >
    > > >

    > >
    > >
    > >


  5. #5
    David
    Guest

    Re: Open a file do a macro ( made) and open next succesive file

    No kiddin Sherlock!
    You must be a democrat...pointing out the negative with no solution.

    "Lucas Swanson" wrote:

    > That is not the way GetOpenFilename works. GetOpenFilename launches a dialog
    > box asking the user to select which files should be opened.
    >
    > "David" wrote:
    >
    > > Do you know anyway when using the Application.GetOpenFilename function to use
    > > a specific filename that is a defined string?
    > > Example: SName is BP-Sarasota.xls
    > > Tried fname=Application.GetOpenFilename(SName) but no joy.
    > > Any ideas?
    > >
    > > David
    > >
    > > "Bernie Deitrick" wrote:
    > >
    > > > Here's the general idea:
    > > >
    > > > Sub OpenUserSelectedFiles()
    > > > Dim i As Integer
    > > > Dim filearray As Variant
    > > >
    > > > filearray = Application.GetOpenFilename( _
    > > > Title:="Select the files to process", MultiSelect:=True)
    > > > If IsArray(filearray) Then
    > > > For i = LBound(filearray) To UBound(filearray)
    > > > Workbooks.Open filearray(i)
    > > > 'Call your macro here
    > > > ActiveWorkbook.Close False
    > > > Next i
    > > > Else:
    > > > MsgBox "You clicked cancel"
    > > > End If
    > > > End Sub
    > > >
    > > > HTH,
    > > > Bernie
    > > > MS Excel MVP
    > > >
    > > >
    > > > "SVTman74" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Open a file do a macro ( made) and open next succesive file
    > > > >
    > > > > File name yyyy-mm-ddxxxx.csv <--- the date is the creation date.
    > > > > can I have excel run the macro to auto matically open first file in dir run
    > > > > its parse and save ( this is done) THEN open the next file and continue?
    > > > >
    > > > >
    > > >
    > > >
    > > >


  6. #6
    Lucas Swanson
    Guest

    Re: Open a file do a macro ( made) and open next succesive file

    Sorry, I did not have time to post a full reply.

    If you want to open a file with a given filename the following code should
    do it for you:

    Workbooks.Open "FileName"

    where "FileName" is the name of whatever file you want to open.

    "David" wrote:

    > No kiddin Sherlock!
    > You must be a democrat...pointing out the negative with no solution.
    >
    > "Lucas Swanson" wrote:
    >
    > > That is not the way GetOpenFilename works. GetOpenFilename launches a dialog
    > > box asking the user to select which files should be opened.
    > >
    > > "David" wrote:
    > >
    > > > Do you know anyway when using the Application.GetOpenFilename function to use
    > > > a specific filename that is a defined string?
    > > > Example: SName is BP-Sarasota.xls
    > > > Tried fname=Application.GetOpenFilename(SName) but no joy.
    > > > Any ideas?
    > > >
    > > > David
    > > >
    > > > "Bernie Deitrick" wrote:
    > > >
    > > > > Here's the general idea:
    > > > >
    > > > > Sub OpenUserSelectedFiles()
    > > > > Dim i As Integer
    > > > > Dim filearray As Variant
    > > > >
    > > > > filearray = Application.GetOpenFilename( _
    > > > > Title:="Select the files to process", MultiSelect:=True)
    > > > > If IsArray(filearray) Then
    > > > > For i = LBound(filearray) To UBound(filearray)
    > > > > Workbooks.Open filearray(i)
    > > > > 'Call your macro here
    > > > > ActiveWorkbook.Close False
    > > > > Next i
    > > > > Else:
    > > > > MsgBox "You clicked cancel"
    > > > > End If
    > > > > End Sub
    > > > >
    > > > > HTH,
    > > > > Bernie
    > > > > MS Excel MVP
    > > > >
    > > > >
    > > > > "SVTman74" <[email protected]> wrote in message
    > > > > news:[email protected]...
    > > > > > Open a file do a macro ( made) and open next succesive file
    > > > > >
    > > > > > File name yyyy-mm-ddxxxx.csv <--- the date is the creation date.
    > > > > > can I have excel run the macro to auto matically open first file in dir run
    > > > > > its parse and save ( this is done) THEN open the next file and continue?
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > > >


+ 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