I have an interesting issue that you may be able to shed
some light on. I have a macro in spreadsheet that opens a
csv file that is in the same directory, manipulates it and
saves it to another folder. The csv file file always has
the same name and that name is hard-coded into the macro
with Workbooks.Open Filename:=ThisWorkbook.Path & "\R99DFG
PARIS (YTD).csv"
The csv file is placed there by an automated process over
which I have no control and each time the automated process
uploads a new file, it first removes the previous one
(daily). The macro has worked happily for over one year.
Now, the source has changed the file name to match an
internal requirement such that the name now takes form of
R99DFG xxxx (YTD).csv, where xxxx is always a random hex
number that I do not know in advance.
I therefore changed the line of code in my macro to
Workbooks.Open Filename:=ThisWorkbook.Path &
"\R99DFG*.csv", thinking that it would act as a wildcard
but all I get is a 'file not found' error.
I have tried with "\R99DFG" & "*" & ".csv" as I have seen
it written this way before but to no avail. Are wildcards
not accepted in Excel 2010 macros, or not acceptable with
this function?
I am more interested to find out why this does not work
than getting suggestions for an alternative piece of code
e.g. I know I could get the operator to select the file
manually during the process as an option.
some light on. I have a macro in spreadsheet that opens a
csv file that is in the same directory, manipulates it and
saves it to another folder. The csv file file always has
the same name and that name is hard-coded into the macro
with Workbooks.Open Filename:=ThisWorkbook.Path & "\R99DFG
PARIS (YTD).csv"
The csv file is placed there by an automated process over
which I have no control and each time the automated process
uploads a new file, it first removes the previous one
(daily). The macro has worked happily for over one year.
Now, the source has changed the file name to match an
internal requirement such that the name now takes form of
R99DFG xxxx (YTD).csv, where xxxx is always a random hex
number that I do not know in advance.
I therefore changed the line of code in my macro to
Workbooks.Open Filename:=ThisWorkbook.Path &
"\R99DFG*.csv", thinking that it would act as a wildcard
but all I get is a 'file not found' error.
I have tried with "\R99DFG" & "*" & ".csv" as I have seen
it written this way before but to no avail. Are wildcards
not accepted in Excel 2010 macros, or not acceptable with
this function?
I am more interested to find out why this does not work
than getting suggestions for an alternative piece of code
e.g. I know I could get the operator to select the file
manually during the process as an option.