Default file location in VBA?

  • Thread starter Thread starter c mateland
  • Start date Start date
C

c mateland

Hello.

1) In VBA, how can I capture the "Default File Location" on the user's
machine?

It's simple to do in Excel (DefaultFilePath), but I can't find an
object or method in PPT, and I've read as much archives as I could
find.

2) Then how can I include code to change the current path to that
location after I open an existing file in that code?

I've tried the common tactic of
ChDrive "C"
ChDir "C:\Documents and Settings\Chuck\My Documents"
but it doesn't seem to work in PPT.

What I've got is I made an addin that opens a file upon PPT launch,
which unfortunately changes the current path to that file. I want it
changed back to the original default file location the user had set.

3) If nothing exists to do this, is there a way to first read the
location of the the default file that typically opens upon PPT launch?
But that can be tricky since the addin, via AutoOpen, opens a file and
I think it then prevents the default blank file from opening. Right?

4) Any other ideas to capture and restore the default file location?

Thanks,
Chuck
 
The value you want is stored in the registry under:

HKCU\Software\Microsoft\Office\xx.0\PowerPoint\RecentFolderList
RegExpandSZ: Default=path

where xx = PPT version

Problem is, PPT reads most of this stuff at startup, writes it back at
shutdown, so changes you make from an addin are:

- Ignored during the session and
- Overwritten at shutdown

Friendly of it.

You might be able to check this value, retain it, do your business, then save a
dummy file back to the same location and then delete it.
 
Yikes, that sounds complex. I don't know how to capture such a setting
value with code.

Instead, I'm testing this approach: I'll change the file-open code to
include Untitled=True. In brief tests, that left the default file
location alone. It sort of opens the file as a template, which is what
it's used as anyway. How does that sound?

-Chuck
 
C mateland said:
Yikes, that sounds complex. I don't know how to capture such a setting
value with code.

Instead, I'm testing this approach: I'll change the file-open code to
include Untitled=True. In brief tests, that left the default file
location alone. It sort of opens the file as a template, which is what
it's used as anyway. How does that sound?

I haven't tried it myself but it sounds like it's worth a shot.
 
Back
Top