PDA

View Full Version : Outlook - VBA Get Working Directory



Cheesecube
04-23-2020, 07:42 PM
Hi, I want to get the working directory when coding in Outlook VBA.

I understand that for Excel, there is ThisWorkbook.Path or ActiveWorkbook.Path

For Word there is ThisDocument.Path and ActiveDocument.Path

But what about Outlook? My code isn't running from a file.

- How do you get the working directory in Outlook?
- Where does this working directory point to by default?
- Does this directory ever change depending on how you use Outlook?

gmayor
04-23-2020, 09:02 PM
Outlook doesn't normally use folders in the same manner as Excel or Word. What is it that you are trying to do?

Cheesecube
04-23-2020, 09:55 PM
I am reading settings variables from a config Excel file but I want the location of this Excel file to be standardized to work regardless of the machine I am running the Outlook VBA code from

- I want to know where to place this Config.xlsx file
- How to refer to the Config.xlsx in code
- Location should be somewhere convenient in an existing folder

In Word or Excel we can place it in the same folder as the document/workbook with the code,
what is the equivalent location in Outlook?

gmayor
04-24-2020, 06:41 AM
You could save it in the user's Documents folder e.g.

strPath = Environ("USERPROFILE") & "\Documents\Config.xlsx"