ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting a File name: (https://www.excelbanter.com/excel-programming/272919-setting-file-name.html)

Ben E

Setting a File name:
 
Hi guy's I'm looking for a little help,

What I am looking to do is set the name of the active
workbook as a variable,

The aim is that any one of a set number of files is opened
(say File A), A set predetermined data is copied to
another file (File B), and the source file (File A) is to
be closed, I have been able to set most of the macro
however my problem is that the name of file a is variable
and not likely to be used more than twice, I can set the
VBA to find the name of the file through (Windows
(ThisWorkbook.Name)), but I'm not sure how to set it as a
variable.

Any help in this matter would be appreciated.

Ben E


Mike[_31_]

Setting a File name:
 
VariableName = ActiveWorkbook.Name

Then when you want to close it,
Workbooks(VariableName).Close SaveChanges:=True 'or false

Maybe add Application.CutCopyMode = False prior to closing
in case you have recently copied a large chunk of data.

-----Original Message-----
Hi guy's I'm looking for a little help,

What I am looking to do is set the name of the active
workbook as a variable,

The aim is that any one of a set number of files is

opened
(say File A), A set predetermined data is copied to
another file (File B), and the source file (File A) is to
be closed, I have been able to set most of the macro
however my problem is that the name of file a is

variable
and not likely to be used more than twice, I can set the
VBA to find the name of the file through (Windows
(ThisWorkbook.Name)), but I'm not sure how to set it as a
variable.

Any help in this matter would be appreciated.

Ben E

.



All times are GMT +1. The time now is 03:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com