I am creating a macro that will need to open another workbook on a server. I originally set the file path of the "server workbook" to a public constant variable to be used by all modules/procedures.
Once I complete this project, it will be used at different sites with their own servers, so the file path will change. The other sites are not VBA proficient, so my answer to this was to have a cell on Sheet1 that contains the file path and the public constant variable will refer to that cell. However, when I debug the project, I get a compile error stating "Constant Expression Required" and the ".Range" part of the code is highlighted. (If the whole file path is coded in, I do not get this error)
Is there a way to get this to work? Or am I going to have to explain to others how to change the path in the macro?
Problem Code:
Working Code:
Once I complete this project, it will be used at different sites with their own servers, so the file path will change. The other sites are not VBA proficient, so my answer to this was to have a cell on Sheet1 that contains the file path and the public constant variable will refer to that cell. However, when I debug the project, I get a compile error stating "Constant Expression Required" and the ".Range" part of the code is highlighted. (If the whole file path is coded in, I do not get this error)
Is there a way to get this to work? Or am I going to have to explain to others how to change the path in the macro?
Problem Code:
Code:
Public Const lotdatalocation As String = ThisWorkbook.Worksheets("Raw Materials").Range("C30") & "\Lotdata.xls"
Code:
Public Const lotdatalocation As String = "C:\Documents and Settings\cterry\Desktop\MCDS 4.0\Lotdata.xls"