relative path

J

Jorge mst

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
 
J

JLGWhiz

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.
 

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