Searching for a root directoty

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
 
G

Guest

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"
 
G

Guest

It works just as expected, ¿where you learn to VB programation??
some book that I could buy???
 
T

Tom Ogilvy

Just some added information.

ThisWorkbook.Path

gives just the path.

workbooks.Open thisworkbook.Path & "\registros.xls"
 
G

Guest

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.
 

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

Top