ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Target (https://www.excelbanter.com/excel-worksheet-functions/77875-target.html)

Param

Target
 
hi, I have macro command that link file A to file B
Q: anyway to write this command without mention the directory e.g
"C:\temp\b.xls"
because all the file within one folder (e.g temp). I counter problem when
copy this folder to another PC, where the location are not same. Like copy to
my document and run it.

sub foo()
dim wbk as workbook
set wbk=activeworkbook
workbooks.open "C:\temp\b.xls"
wbk.close
end sub


Daniel CHEN

Target
 
Try to use the following which opens the file in the same directory as the
active workbook:

sub foo()
dim wbk as workbook
set wbk=activeworkbook
workbooks.open Activeworkbook.Path&"\b.xls"
wbk.close
end sub

--
Best regards,
---
Yongjun CHEN
=================================
XLDataSoft - Data Analysis Expert, Excel/VBA Specialist
- - - - www.XLDataSoft.com - - - -
Free Excel-Based Data Processing Tool is Available for Download



"Param" wrote in message
...
hi, I have macro command that link file A to file B
Q: anyway to write this command without mention the directory e.g
"C:\temp\b.xls"
because all the file within one folder (e.g temp). I counter problem when
copy this folder to another PC, where the location are not same. Like copy
to
my document and run it.

sub foo()
dim wbk as workbook
set wbk=activeworkbook
workbooks.open "C:\temp\b.xls"
wbk.close
end sub





All times are GMT +1. The time now is 05:56 AM.

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