ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting Path for Word AND Excel (https://www.excelbanter.com/excel-programming/380008-re-setting-path-word-excel.html)

Cindy M.

Setting Path for Word AND Excel
 
Hi ?B?I0RJVi8w?=,

Best would probably be to query it in every macro. I think that would be faster
than writing it to an outside file and having to open and read that.

I suppose you could save it as a custom document property in one or more files,
but I'm not sure that would be safer or more efficient. The DSOFile.exe should
let you do that without actually opening the files. You'll find information on
working with this on the word.mvps.org website.

I've been looking at all the posts I could find about globals but I can't get
a clear idea of how to set up a shared folder as the default. The Italian VBE
help files aren't much use.
Background: I have a Word .dot and an Excel .xla in the same folder. All
related secondary files (Excel Worksheets, other Word templates etc.) are in
this one folder that also contains the sub-folders for archiving new docs and
books that various Word and Excel macros create. I have Word and Excel (more
or less) happily talking to each other, creating stuff, updating stuff and
saving it correctly thanks to posts here and some other links (particularly
www.erlandsendata.no).
My remaining problem is that I need all folder tree references to work
whether I place this folder in "C:\" or
"F:\Documents\Whatever\SomethingElse\YetAnothe r\".
I figure one way in Excel would be to get ThisWorkbook.Path for the .xla
template Dim it as a String and there's probably something similar in Word.
But how exactly do I set these values as something I can call up in later
macros and UserForms based on these templates ?


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)


#DIV/0

Setting Path for Word AND Excel
 
Hi Cindy,
Not sure I understand your answer. Do you think I should start every single
Excel and Word macro with a check to find the base file path and set a value
to use within that macro ?
Seems clumsy. Is there really no way to set that as a global value ?


--
David M


"Cindy M." wrote:

Hi ?B?I0RJVi8w?=,

Best would probably be to query it in every macro. I think that would be faster
than writing it to an outside file and having to open and read that.

I suppose you could save it as a custom document property in one or more files,
but I'm not sure that would be safer or more efficient. The DSOFile.exe should
let you do that without actually opening the files. You'll find information on
working with this on the word.mvps.org website.

I've been looking at all the posts I could find about globals but I can't get
a clear idea of how to set up a shared folder as the default. The Italian VBE
help files aren't much use.
Background: I have a Word .dot and an Excel .xla in the same folder. All
related secondary files (Excel Worksheets, other Word templates etc.) are in
this one folder that also contains the sub-folders for archiving new docs and
books that various Word and Excel macros create. I have Word and Excel (more
or less) happily talking to each other, creating stuff, updating stuff and
saving it correctly thanks to posts here and some other links (particularly
www.erlandsendata.no).
My remaining problem is that I need all folder tree references to work
whether I place this folder in "C:\" or
"F:\Documents\Whatever\SomethingElse\YetAnothe r\".
I figure one way in Excel would be to get ThisWorkbook.Path for the .xla
template Dim it as a String and there's probably something similar in Word.
But how exactly do I set these values as something I can call up in later
macros and UserForms based on these templates ?


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)



Cindy M.

Setting Path for Word AND Excel
 
Hi ?B?I0RJVi8w?=,

Not sure I understand your answer. Do you think I should start every single
Excel and Word macro with a check to find the base file path and set a value
to use within that macro ?
Seems clumsy. Is there really no way to set that as a global value ?

It depends on how everything is supposed to work. A VBA project can have
"global variables", but they can go out of scope (the assigned values are lost
because the memory has been released). Since we don't know the details of your
entire project, it's therefore difficult to give a definitive answer.

Based on experience, you'd at least want to have a function at the beginning of
each procedure, or set of linked procedures, that requires this information to
check whether a global variable contains the information (Len(theVariable) 0)
and if it doesn't (empty string), call the procedure that gets the information.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)



All times are GMT +1. The time now is 04:12 AM.

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