ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   relative path (https://www.excelbanter.com/excel-programming/417500-relative-path.html)

Jorge mst

relative path
 
Hello
Sorry if I don't make myself clear.

I have a directory #1 with:
- €œword document.docx€ -- the content is: abc
- €œexcel document.xlsx€
and another directory #2 with:
- €œword document.docx€ --the content is: def

When I move €œexcel document.xlsx€ from directory #1 to directory #2 I need
that the content of the cell, in excel, change from "abc" to "def". The cell
in excel have to be make with a relative path and not with an absolute path
to the file €œword document.docx€.

Can you help me?
Thanks

JLGWhiz

relative path
 
You could probably control it with an If statement in the Workbook_Open event.

expl: If ThisWorkbook.Path = C:\MyDocuments\directory #1\ Then
Workbooks(exceldocument.xlsx).Range("A1") = "abc"
ElseIf ThisWorkbook.Path = C:\MyDocuments\directory #2\ Then
Workbooks(exceldocument.xlsx).Range("A1") = "def"
End If

Then in your underlying code in the Excel file, use a variable to reference
Range("A1") to detect the abc or def.


"Jorge mst" wrote:

Hello
Sorry if I don't make myself clear.

I have a directory #1 with:
- €œword document.docx€ -- the content is: abc
- €œexcel document.xlsx€
and another directory #2 with:
- €œword document.docx€ --the content is: def

When I move €œexcel document.xlsx€ from directory #1 to directory #2 I need
that the content of the cell, in excel, change from "abc" to "def". The cell
in excel have to be make with a relative path and not with an absolute path
to the file €œword document.docx€.

Can you help me?
Thanks



All times are GMT +1. The time now is 06:52 AM.

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