From: shiloh13 on
Please Help!!

I have a master file called "All Reports.xls" that opens up various Reports
files(Ex: ABC_G016_GPUS.xls, BCD_G027_GPUS.xls, JKL_G034_GPUS.xls). The
Report files are in the same network folder as the master file and are
updated frequently. The Report files also have names that constantly change
when they are updated. The only part of the filename that does not change
begins with "G" followed by 3 numbers. By reading previous posts, I was able
to figure out how to open the "G016" Report file with the code below.

Workbooks.Open ActiveWorkbook.Path & "ABC_G016_GPUS.xls"

How do I open the file by only the "G016" part of the filename? I tried the
code below, but it did not work:

Workbooks.Open ActiveWorkbook.Path & "*" & G016 & "*.xls"

I appreciate your help!!

From: Gary Keramidas on
maybe something like this:

Sub test()
Dim FileToOpen As String

FileToOpen = Dir(ActiveWorkbook.Path & "*" & "G016" & "*.xls")
If FileToOpen <> "" Then
Workbooks.Open FileToOpen
End If

End Sub


--


Gary Keramidas
Excel 2003


"shiloh13" <u59050(a)uwe> wrote in message news:a5b747aa8da6d(a)uwe...
> Please Help!!
>
> I have a master file called "All Reports.xls" that opens up various
> Reports
> files(Ex: ABC_G016_GPUS.xls, BCD_G027_GPUS.xls, JKL_G034_GPUS.xls). The
> Report files are in the same network folder as the master file and are
> updated frequently. The Report files also have names that constantly
> change
> when they are updated. The only part of the filename that does not change
> begins with "G" followed by 3 numbers. By reading previous posts, I was
> able
> to figure out how to open the "G016" Report file with the code below.
>
> Workbooks.Open ActiveWorkbook.Path & "ABC_G016_GPUS.xls"
>
> How do I open the file by only the "G016" part of the filename? I tried
> the
> code below, but it did not work:
>
> Workbooks.Open ActiveWorkbook.Path & "*" & G016 & "*.xls"
>
> I appreciate your help!!
>

From: Rick Rothstein on
> Workbooks.Open FileToOpen

The above line from your code should be this...

Workbooks.Open ActiveWorkbook.Path & FileToOpen

Since the Dir function returns only the file's name (without the path
associated with it).

--
Rick (MVP - Excel)



"Gary Keramidas" <gkeramidas(a)MSN.com> wrote in message
news:O$NCdzvzKHA.1236(a)TK2MSFTNGP06.phx.gbl...
> maybe something like this:
>
> Sub test()
> Dim FileToOpen As String
>
> FileToOpen = Dir(ActiveWorkbook.Path & "*" & "G016" & "*.xls")
> If FileToOpen <> "" Then
> Workbooks.Open FileToOpen
> End If
>
> End Sub
>
>
> --
>
>
> Gary Keramidas
> Excel 2003
>
>
> "shiloh13" <u59050(a)uwe> wrote in message news:a5b747aa8da6d(a)uwe...
>> Please Help!!
>>
>> I have a master file called "All Reports.xls" that opens up various
>> Reports
>> files(Ex: ABC_G016_GPUS.xls, BCD_G027_GPUS.xls, JKL_G034_GPUS.xls). The
>> Report files are in the same network folder as the master file and are
>> updated frequently. The Report files also have names that constantly
>> change
>> when they are updated. The only part of the filename that does not
>> change
>> begins with "G" followed by 3 numbers. By reading previous posts, I was
>> able
>> to figure out how to open the "G016" Report file with the code below.
>>
>> Workbooks.Open ActiveWorkbook.Path & "ABC_G016_GPUS.xls"
>>
>> How do I open the file by only the "G016" part of the filename? I tried
>> the
>> code below, but it did not work:
>>
>> Workbooks.Open ActiveWorkbook.Path & "*" & G016 & "*.xls"
>>
>> I appreciate your help!!
>>
>
From: Gary Keramidas on
thanks

--


Gary Keramidas
Excel 2003


"Rick Rothstein" <rick.newsNO.SPAM(a)NO.SPAMverizon.net> wrote in message
news:OBXzy8vzKHA.6112(a)TK2MSFTNGP05.phx.gbl...
>> Workbooks.Open FileToOpen
>
> The above line from your code should be this...
>
> Workbooks.Open ActiveWorkbook.Path & FileToOpen
>
> Since the Dir function returns only the file's name (without the path
> associated with it).
>
> --
> Rick (MVP - Excel)
>
>
>
> "Gary Keramidas" <gkeramidas(a)MSN.com> wrote in message
> news:O$NCdzvzKHA.1236(a)TK2MSFTNGP06.phx.gbl...
>> maybe something like this:
>>
>> Sub test()
>> Dim FileToOpen As String
>>
>> FileToOpen = Dir(ActiveWorkbook.Path & "*" & "G016" & "*.xls")
>> If FileToOpen <> "" Then
>> Workbooks.Open FileToOpen
>> End If
>>
>> End Sub
>>
>>
>> --
>>
>>
>> Gary Keramidas
>> Excel 2003
>>
>>
>> "shiloh13" <u59050(a)uwe> wrote in message news:a5b747aa8da6d(a)uwe...
>>> Please Help!!
>>>
>>> I have a master file called "All Reports.xls" that opens up various
>>> Reports
>>> files(Ex: ABC_G016_GPUS.xls, BCD_G027_GPUS.xls, JKL_G034_GPUS.xls). The
>>> Report files are in the same network folder as the master file and are
>>> updated frequently. The Report files also have names that constantly
>>> change
>>> when they are updated. The only part of the filename that does not
>>> change
>>> begins with "G" followed by 3 numbers. By reading previous posts, I was
>>> able
>>> to figure out how to open the "G016" Report file with the code below.
>>>
>>> Workbooks.Open ActiveWorkbook.Path & "ABC_G016_GPUS.xls"
>>>
>>> How do I open the file by only the "G016" part of the filename? I tried
>>> the
>>> code below, but it did not work:
>>>
>>> Workbooks.Open ActiveWorkbook.Path & "*" & G016 & "*.xls"
>>>
>>> I appreciate your help!!
>>>
>>

From: OssieMac on

I think that the backslash should also be included in both lines. Seems to
be OK without if the current default directory is also the activeworkbook
directory but can one be sure of that.

Sub test()

Dim FileToOpen As String

FileToOpen = Dir(ActiveWorkbook.Path & "\" & "*" & "G016" & "*.xls")

If FileToOpen <> "" Then
Workbooks.Open ActiveWorkbook.Path & "\" & FileToOpen
End If

End Sub

--
Regards,

OssieMac


"Rick Rothstein" wrote:

> > Workbooks.Open FileToOpen
>
> The above line from your code should be this...
>
> Workbooks.Open ActiveWorkbook.Path & FileToOpen
>
> Since the Dir function returns only the file's name (without the path
> associated with it).
>
> --
> Rick (MVP - Excel)
>
>
>
> "Gary Keramidas" <gkeramidas(a)MSN.com> wrote in message
> news:O$NCdzvzKHA.1236(a)TK2MSFTNGP06.phx.gbl...
> > maybe something like this:
> >
> > Sub test()
> > Dim FileToOpen As String
> >
> > FileToOpen = Dir(ActiveWorkbook.Path & "*" & "G016" & "*.xls")
> > If FileToOpen <> "" Then
> > Workbooks.Open FileToOpen
> > End If
> >
> > End Sub
> >
> >
> > --
> >
> >
> > Gary Keramidas
> > Excel 2003
> >
> >
> > "shiloh13" <u59050(a)uwe> wrote in message news:a5b747aa8da6d(a)uwe...
> >> Please Help!!
> >>
> >> I have a master file called "All Reports.xls" that opens up various
> >> Reports
> >> files(Ex: ABC_G016_GPUS.xls, BCD_G027_GPUS.xls, JKL_G034_GPUS.xls). The
> >> Report files are in the same network folder as the master file and are
> >> updated frequently. The Report files also have names that constantly
> >> change
> >> when they are updated. The only part of the filename that does not
> >> change
> >> begins with "G" followed by 3 numbers. By reading previous posts, I was
> >> able
> >> to figure out how to open the "G016" Report file with the code below.
> >>
> >> Workbooks.Open ActiveWorkbook.Path & "ABC_G016_GPUS.xls"
> >>
> >> How do I open the file by only the "G016" part of the filename? I tried
> >> the
> >> code below, but it did not work:
> >>
> >> Workbooks.Open ActiveWorkbook.Path & "*" & G016 & "*.xls"
> >>
> >> I appreciate your help!!
> >>
> >
> .
>