For the life of me I can not remember how to add a variable name to a file
path.
I have converted a file from text to xls and have saved it as myfile - date
in mmddyy

I have tried workbooks("myfile-"&date).close savechanges:=false.

but it does not like that.

RE: Workbooks property by JLGWhiz

JLGWhiz
Fri Mar 14 16:12:02 CDT 2008

ActiveWorkbook.SaveAs FileName:=Workbooks(myFile & Format(Date, "mmddyy")

You can't add the date and us SaveChanges = False. It won't save anything.

"Rpettis31" wrote:

> For the life of me I can not remember how to add a variable name to a file
> path.
> I have converted a file from text to xls and have saved it as myfile - date
> in mmddyy
>
> I have tried workbooks("myfile-"&date).close savechanges:=false.
>
> but it does not like that.

RE: Workbooks property by Rpettis31

Rpettis31
Fri Mar 14 22:52:01 CDT 2008

The file has already been saved. I am copying data from this file and
pasting it to another workbook. I am just looking to close the workbook now.

"JLGWhiz" wrote:

> ActiveWorkbook.SaveAs FileName:=Workbooks(myFile & Format(Date, "mmddyy")
>
> You can't add the date and us SaveChanges = False. It won't save anything.
>
> "Rpettis31" wrote:
>
> > For the life of me I can not remember how to add a variable name to a file
> > path.
> > I have converted a file from text to xls and have saved it as myfile - date
> > in mmddyy
> >
> > I have tried workbooks("myfile-"&date).close savechanges:=false.
> >
> > but it does not like that.

RE: Workbooks property by JLGWhiz

JLGWhiz
Sat Mar 15 10:36:00 CDT 2008

Either of these should work, depending on which workbook is active and which
contains the code that is running.


ActiveWorkbook.Close SaveChanges:=False
Workbooks(myFile & "-" & date) SaveChanges:=False

Using date as a variable in not a good idea since Date is a reserved word in
VB.
If you use it as a variable then it should be modified. i.e. myDate, edate,
etc.
Otherwise, it can create problems during runtime.

"Rpettis31" wrote:

> The file has already been saved. I am copying data from this file and
> pasting it to another workbook. I am just looking to close the workbook now.
>
> "JLGWhiz" wrote:
>
> > ActiveWorkbook.SaveAs FileName:=Workbooks(myFile & Format(Date, "mmddyy")
> >
> > You can't add the date and us SaveChanges = False. It won't save anything.
> >
> > "Rpettis31" wrote:
> >
> > > For the life of me I can not remember how to add a variable name to a file
> > > path.
> > > I have converted a file from text to xls and have saved it as myfile - date
> > > in mmddyy
> > >
> > > I have tried workbooks("myfile-"&date).close savechanges:=false.
> > >
> > > but it does not like that.

RE: Workbooks property by JLGWhiz

JLGWhiz
Sat Mar 15 10:48:00 CDT 2008

If you still have problems, then try inserting this code snippet.

fName = ActiveWorkbook.Name
Workbooks(fName).Close SaveChanges:=False

"Rpettis31" wrote:

> The file has already been saved. I am copying data from this file and
> pasting it to another workbook. I am just looking to close the workbook now.
>
> "JLGWhiz" wrote:
>
> > ActiveWorkbook.SaveAs FileName:=Workbooks(myFile & Format(Date, "mmddyy")
> >
> > You can't add the date and us SaveChanges = False. It won't save anything.
> >
> > "Rpettis31" wrote:
> >
> > > For the life of me I can not remember how to add a variable name to a file
> > > path.
> > > I have converted a file from text to xls and have saved it as myfile - date
> > > in mmddyy
> > >
> > > I have tried workbooks("myfile-"&date).close savechanges:=false.
> > >
> > > but it does not like that.

RE: Workbooks property by Rpettis31

Rpettis31
Sat Mar 15 12:15:01 CDT 2008

This worked, Thanks...Its always the easiest answer that seems to always
cause me the most issues.

Thanks alot.
Robert

"JLGWhiz" wrote:

> If you still have problems, then try inserting this code snippet.
>
> fName = ActiveWorkbook.Name
> Workbooks(fName).Close SaveChanges:=False
>
> "Rpettis31" wrote:
>
> > The file has already been saved. I am copying data from this file and
> > pasting it to another workbook. I am just looking to close the workbook now.
> >
> > "JLGWhiz" wrote:
> >
> > > ActiveWorkbook.SaveAs FileName:=Workbooks(myFile & Format(Date, "mmddyy")
> > >
> > > You can't add the date and us SaveChanges = False. It won't save anything.
> > >
> > > "Rpettis31" wrote:
> > >
> > > > For the life of me I can not remember how to add a variable name to a file
> > > > path.
> > > > I have converted a file from text to xls and have saved it as myfile - date
> > > > in mmddyy
> > > >
> > > > I have tried workbooks("myfile-"&date).close savechanges:=false.
> > > >
> > > > but it does not like that.