close

hi, I have macro command that link file A to file B
Q: anyway to write this command without mention the directory e.g
quot;C:\temp\b.xlsquot;
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 quot;C:\temp\b.xlsquot;
wbk.close
end subTry 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.Pathamp;quot;\b.xlsquot;
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
quot;Paramquot; gt; wrote in message
...
gt; hi, I have macro command that link file A to file B
gt; Q: anyway to write this command without mention the directory e.g
gt; quot;C:\temp\b.xlsquot;
gt; because all the file within one folder (e.g temp). I counter problem when
gt; copy this folder to another PC, where the location are not same. Like copy
gt; to
gt; my document and run it.
gt;
gt; sub foo()
gt; dim wbk as workbook
gt; set wbk=activeworkbook
gt; workbooks.open quot;C:\temp\b.xlsquot;
gt; wbk.close
gt; end sub
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()