Setting Current/Working Directory for PowerPoint process through COM Automation

  • Thread starter Thread starter chrismo
  • Start date Start date
C

chrismo

Our application launches PowerPoint through COM automation, and we're
wondering if there's some way to set PowerPoint's current directory to
match the directory of the presentation file opened. I don't see a
way, and I'm not sure it would make sense for this to be surfaced in
the first place, but thought I'd ask anyway.
 
Chrismo said:
Our application launches PowerPoint through COM automation, and we're
wondering if there's some way to set PowerPoint's current directory to
match the directory of the presentation file opened. I don't see a
way, and I'm not sure it would make sense for this to be surfaced in
the first place, but thought I'd ask anyway.

PowerPoint doesn't have a current directory as such; it uses the Windows
current directory.

Under most circumstances, when it opens a PPT file, it sets the current
directory to the directory the file's in, but you can force it using ChDir and
ChDrive (in VB/VBA; if you're working in some other language, I imagine there's
something similar)
 
Under most circumstances, when it opens a PPT file, it sets the current
directory to the directory the file's in,

Opening a Presentation through COM automation does not seem to set the
process's current directory to match the presentation's directory.
(Neither does opening presentations from the Recent File List from
within PowerPoint itself (at least in 2003)).
but you can force it using ChDir and
ChDrive (in VB/VBA; if you're working in some other language, I imagine there's
something similar)

I'm working through the COM automation interfaces from another process
- I can't make a local ChDir call across processes like that (AFAIK).
 
Opening a Presentation through COM automation does not seem to set the
process's current directory to match the presentation's directory.
(Neither does opening presentations from the Recent File List from
within PowerPoint itself (at least in 2003)).

Aha.

I know about the MRU list (and that applies to all versions back to '97, by the
away). That's why I hedged a bit with "under most circumstances ...". That's a
subtle little glitch of PPT's. You've got a good eye.

Didn't know that the same was true of COM automation. Thanks for that.
I'm working through the COM automation interfaces from another process
- I can't make a local ChDir call across processes like that (AFAIK).

Dang. And on further prodding, it starts to look like PPT does start up with its
own default path; that seems to be the path to the shortcut used to start it up (if
done manually).

Can you call a routine within PPT itself? You can do this via COM from VB apps, I
know.
 
Create a PPA, load it via COM interface and then launch a function within
the PPA which will execute the ChDir.
This works, I've employed it many times.


--
Regards,
Shyam Pillai

Animation Carbon: Copy/Paste/Share animation libraries.
www.animationcarbon.com
 
[I thought I posted this already, so I may get a dup - sorry]

Under most circumstances, when it opens a PPT file, it sets the current
directory to the directory the file's in,

Through the COM automation, opening a Presentation does not seem to
set the current directory to match the presentation file's directory.

(FWIW, opening presentations in PowerPoint 2003 from the Recent File
List doesn't update it either).

but you can force it using ChDir and
ChDrive (in VB/VBA; if you're working in some other language, I imagine there's
something similar)

I'm controlling the PowerPoint process through COM automation, so I
know of no way to make a call from another process to change the
working directory in PowerPoint itself.
 
[I thought I posted this already, so I may get a dup - sorry]

No biggie ... see Shyam's and my reply to your earlier post.
Shyam's clearly enunciated what I was trying clumsily to get across. ;-)
 
Steve said:
Can you call a routine within PPT itself? You can do this via COM from VB apps, I
know.

Can you give me more detail? I don't have enough context in my brain to
understand the question :-)
 
Steve said:
Shyam's clearly enunciated what I was trying clumsily to get across. ;-)

Could one of you flesh out the "Create a PPA" part? Is this a separate,
manual preparatory step, or something that can be done on-the-fly at
runtime via COM automation?
 
Chris,
It would be simpler just to create the PPA since you want the function
present in there.
Check out the PPA faq on links to create the PPA.
http://skp.mvps.org/ppafaq.htm

Create a function in the PPA, lets say - ChangeFolder() and perform the
operation of changing the folder.

Now from your COM interface, load this add-in programmatically (See Addins
method) and then invoke the ChangeFolder routine.

Call oPPT.Run("xyz.ppa!ChangeFolder")

That should do it.
--
Regards,
Shyam Pillai

Animation Carbon: Copy/Paste/Share animation libraries.
www.animationcarbon.com
 
Could one of you flesh out the "Create a PPA" part? Is this a separate,
manual preparatory step, or something that can be done on-the-fly at
runtime via COM automation?

PPA = PowerPoint Addin

These can be installed to load when PPT starts up.

See the VBA programming section of the PPT FAQ for more info (url below)
 
Back
Top