+ Reply to Thread
Results 1 to 4 of 4

open a file in VB that the date changes every day.

  1. #1
    Michael from Austin
    Guest

    open a file in VB that the date changes every day.

    What if the file name is always preceeded by the date. How did I get a macro
    to open up a file that is named the same all the time, but has the date at
    the end always change?

    --
    Regards,
    Michael

  2. #2
    Mike Fogleman
    Guest

    Re: open a file in VB that the date changes every day.

    Which is it?
    > What if the file name is always preceeded by the date.

    DateFilename
    > but has the date at the end always change?

    FilenameDate

    Either way the filename would be like this for today's date:

    Sub test()
    Dim MyDate As String
    Dim MyFile As String

    MyDate = Format(Date, "mm_dd_yy")
    MyFile = "SomeFile " & MyDate & ".xls" '= "SomeFile 10_05_05.xls"
    'or
    MyFile = MyDate & " SomeFile.xls" '= "10_05_05 SomeFile.xls"
    End Sub

    Mike F

    "Michael from Austin" <MichaelfromAustin@discussions.microsoft.com> wrote in
    message news:757A6A26-6FEA-45B2-A4DD-277C7E489DFC@microsoft.com...
    > What if the file name is always preceeded by the date. How did I get a
    > macro
    > to open up a file that is named the same all the time, but has the date at
    > the end always change?
    >
    > --
    > Regards,
    > Michael




  3. #3
    Michael from Austin
    Guest

    Re: open a file in VB that the date changes every day.

    I'm still having issues and it is beyond me. Where is what I did..

    'Defining today

    Dim Today As String
    Today = Format(Date, "mm-dd-yy")

    'Opening file NI WA Subinventory Trasactions " & Today &".xls Current file
    is saved
    ' as " NI WA Subinventory Trasactions 10-24-05

    Windows("NI WA Subinventory Transactions " & Today & ".xls").Activate

    I am getting the error measage "Subscript out of Range."

    What am I doing wrong?

    --
    Regards,
    Michael


    "Mike Fogleman" wrote:

    > Which is it?
    > > What if the file name is always preceeded by the date.

    > DateFilename
    > > but has the date at the end always change?

    > FilenameDate
    >
    > Either way the filename would be like this for today's date:
    >
    > Sub test()
    > Dim MyDate As String
    > Dim MyFile As String
    >
    > MyDate = Format(Date, "mm_dd_yy")
    > MyFile = "SomeFile " & MyDate & ".xls" '= "SomeFile 10_05_05.xls"
    > 'or
    > MyFile = MyDate & " SomeFile.xls" '= "10_05_05 SomeFile.xls"
    > End Sub
    >
    > Mike F
    >
    > "Michael from Austin" <MichaelfromAustin@discussions.microsoft.com> wrote in
    > message news:757A6A26-6FEA-45B2-A4DD-277C7E489DFC@microsoft.com...
    > > What if the file name is always preceeded by the date. How did I get a
    > > macro
    > > to open up a file that is named the same all the time, but has the date at
    > > the end always change?
    > >
    > > --
    > > Regards,
    > > Michael

    >
    >
    >


  4. #4
    Michael from Austin
    Guest

    RE: open a file in VB that the date changes every day.

    I got it. I was not passing the string "Today" into the function..
    Duhhhhhh... Thanks for all your help.....
    --
    Regards,
    Michael


    "Michael from Austin" wrote:

    > What if the file name is always preceeded by the date. How did I get a macro
    > to open up a file that is named the same all the time, but has the date at
    > the end always change?
    >
    > --
    > Regards,
    > Michael


+ 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