Hi everyone.
A quick question. Is it possible to use a variable in a file path that occurs several times in some code. For example, c:Pictureschart.....?
many thanks
Thom
Hi everyone.
A quick question. Is it possible to use a variable in a file path that occurs several times in some code. For example, c:Pictureschart.....?
many thanks
Thom

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
Yes, by declaring a constant or variable, and using & to concatenate strings. For example:
Dim strFile As String
Dim strPath As String
strPath = "C:PicturesChart"
strFile = "Orders.xls"
Workbooks.Open strPath & strFile
...
strFile = "Accounts.xls"
Workbooks.Open strPath & strFile
...
If the path will never change, you can replace
Dim strPath As String
strPath = "C:PicturesChart"
with
Const strPath = "C:PicturesChart"
Many thanks for this Hans