filepath variable

  • Thread starter Thread starter videor
  • Start date Start date
V

videor

Using "filepath = Application.ThisWorkbook.Path" as a statement in a
commandbutton gets me the data I need. Is there any way to put this
statement somewhere so that the data is available in every commandbutton in
the workbook? So I could just use "filepath" everywhere without having to
declare it in every button?\

Using "Public filepath as text" in each worksheet works, but I still have to
make the "filepath=application..." statement in a worksheet.activate section
in every worksheet. I tried putting it in the Workbook declarations section
without success. Any suggestions?

thanks
 
Why use filepath ??

Simple use this in your code
ThisWorkbook.Path & "/" & filenameVar & ".xls"
 
Try putting the variable in a VBA module.

Public strMyPath As String

Public Sub get_path()

strMyPath = ThisWorkbook.Path

End Sub


You can call the sub "get_path()" in the workbook_Open event or something.
 
why not just use thisworkbook.path whenever you need it, instead of putting
in a variable. But if you must:
put this at the top of a normal module not a worksheet or thisworkbook:

public filepath as string

then set it wherever you like, e.g. in workbook_open and/or
workbook_beforesave

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top