Searching for a root directoty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I have a file (invent) in wich a Autoopen() macro was writed, the
autoopen macro opens a file named: c:/mis documentos/registros.xls, this file
is always saved in the same folder as the invent file, ¡How to tell excells
that the file registros.xls is in the same folder than invent.xls so when I
install both files in another computer I don need to change the autoopen
macro???
TVMIA
 
ThisWorkbook.FullName will give the file name including the path. The
following will strip away the file name, giving only the path:
FilePath = Left(ThisWorkbook.FullName,InStrRev(ThisWorkbook.FullName,"\"))
You can then use this in your code to open the workbook:
Workbooks.Open FilePath & "registros.xls"
 
It works just as expected, ¿where you learn to VB programation??
some book that I could buy???
 
Just some added information.

ThisWorkbook.Path

gives just the path.

workbooks.Open thisworkbook.Path & "\registros.xls"
 
There are many books available; I learned mostly by online documentation (but
I have several years experience programming in other languages)

My main sources of info were:
Application help files - look for "Programming Information" in the contents
Web: there are many sites for VBA programming (Google search, or look
through these newsgroups for referenced sites)
Finally, MSDN knowledge base and library were helpful.
 
Back
Top