ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Searching for a root directoty (https://www.excelbanter.com/excel-programming/330121-searching-root-directoty.html)

filo666

Searching for a root directoty
 
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

K Dales[_2_]

Searching for a root directoty
 
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.F ullName,"\"))
You can then use this in your code to open the workbook:
Workbooks.Open FilePath & "registros.xls"


"filo666" wrote:

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


filo666

Searching for a root directoty
 
thanks for your help in this an the other questions.

"K Dales" wrote:

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.F ullName,"\"))
You can then use this in your code to open the workbook:
Workbooks.Open FilePath & "registros.xls"


"filo666" wrote:

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


filo666

Searching for a root directoty
 
It works just as expected, ¿where you learn to VB programation??
some book that I could buy???

"filo666" wrote:

thanks for your help in this an the other questions.

"K Dales" wrote:

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.F ullName,"\"))
You can then use this in your code to open the workbook:
Workbooks.Open FilePath & "registros.xls"


"filo666" wrote:

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


Tom Ogilvy

Searching for a root directoty
 
Just some added information.

ThisWorkbook.Path

gives just the path.

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

--
Regards,
Tom Ogilvy

"K Dales" wrote in message
...
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.F ullName,"\"))
You can then use this in your code to open the workbook:
Workbooks.Open FilePath & "registros.xls"


"filo666" wrote:

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




K Dales[_2_]

Searching for a root directoty
 
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 we
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.

"filo666" wrote:

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

"filo666" wrote:

thanks for your help in this an the other questions.

"K Dales" wrote:

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.F ullName,"\"))
You can then use this in your code to open the workbook:
Workbooks.Open FilePath & "registros.xls"


"filo666" wrote:

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



All times are GMT +1. The time now is 11:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com