ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   filename and path as constant (https://www.excelbanter.com/excel-programming/287492-filename-path-constant.html)

mark kubicki

filename and path as constant
 
easy...

can i define a filename and/or path as a constant?
ex:
Public JobNosDataFile As String
JobNosDataFile = "Job Nos for Timesheets.xls"
Public JobNosDataFilePath As String
JobNosDataFilePath = "\\Server\Files\@ Timesheets\"

can a refernece the name and path like this:
If IsFileOpen("JobNosDataFilePath" & "JobNosDataFile") Then
Workbooks("JobNosDataFile").Save
Workbooks("JobNosDataFile").Close

thanks in advance,
mark



Rob van Gelder[_4_]

filename and path as constant
 
Mark,

You sure can!

Public Const JobNosDataFile As String = "Job Nos for Timesheets.xls"
Public Const JobNosDataFilePath As String = "\\Server\Files\@
Timesheets\"

If IsFileOpen(JobNosDataFilePath & JobNosDataFile) Then
Workbooks(JobNosDataFile).Save
Workbooks(JobNosDataFile).Close
End If

Rob

"mark kubicki" wrote in message
...
easy...

can i define a filename and/or path as a constant?
ex:
Public JobNosDataFile As String
JobNosDataFile = "Job Nos for Timesheets.xls"
Public JobNosDataFilePath As String
JobNosDataFilePath = "\\Server\Files\@ Timesheets\"

can a refernece the name and path like this:
If IsFileOpen("JobNosDataFilePath" & "JobNosDataFile") Then
Workbooks("JobNosDataFile").Save
Workbooks("JobNosDataFile").Close

thanks in advance,
mark






All times are GMT +1. The time now is 09:10 AM.

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