View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gixxer_J_97[_2_] Gixxer_J_97[_2_] is offline
external usenet poster
 
Posts: 206
Default global 'path' declaration

thanks Chip!

just for clarification - can the const be defined in any code module, or
does it need to be defined in the module that it will be used? is there a
way to make it "global" or does defining it as const take care of that?


"Chip Pearson" wrote:

Don't declare it in ThisWorkbook. Declare the constant in a
regular code module. If you do declare it in ThisWorkbook, you
need to reference the variable as ThisWorkbook.docPath.




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Gixxer_J_97" wrote in
message
...
Hi all

i need to have a global 'path' that all of my functions and
subs have access
to, so that if i want to change the path, i need to change it
only in one
place

i have

const docPath="C:\Temp\"

defined in ThisWorkbook, but when i open the workbook and run
any of my
functions trying to reference docPath, it is empty

is defining it as a const in ThisWorkbook not setting it
public?
or do i need to do

public docPath

Private Sub Workbook_Open()
docPath = "C:\Temp\"
End Sub

?

doesn't that allow the path to be changed from other functions?

any suggestions greatly appreciated!

thanks!

J