Bryce Bassett
asked on
Using VBA, how can I display an Insert Picture dialog in PPT 2007, pointing to a directory of my choice
Hi:
Trying to build a macro in VBA, for use in Powerpoint, that presents an InsertPicture dialog pointing to a pre-determined folder. I understand PPT does not give the same access to built-in dialog boxes I have in Word, but is there a workaround?
Here's the code I used to accomplished this in Word:
Dim defpath As String
'Get the present default filepath for pictures
defpath = Options.DefaultFilePath(wd PicturesPa th)
'Change it to desired folder
Options.DefaultFilePath(wd PicturesPa th) = "C:\TemplateDemo\Graphics\ "
With Dialogs(wdDialogInsertPict ure)
.Show
End With
'Change the default filepath back to the original default
Options.DefaultFilePath(wd PicturesPa th) = defpath
I already tried substituting "pp.." for "wd..." but no such luck.
I also found online the following snippet which does display an insert picture dialog (pointing to the default "my pictures" location) in PPT 2007, but it was clearly coded for legacy versions.
Application.CommandBars("M enu bar").Controls("&Insert"). Controls(" &Picture") .Controls( "&From File...").Execute
I'd be happy to use this if I can control where it points.
Any suggestions?
Thanks in advance
Trying to build a macro in VBA, for use in Powerpoint, that presents an InsertPicture dialog pointing to a pre-determined folder. I understand PPT does not give the same access to built-in dialog boxes I have in Word, but is there a workaround?
Here's the code I used to accomplished this in Word:
Dim defpath As String
'Get the present default filepath for pictures
defpath = Options.DefaultFilePath(wd
'Change it to desired folder
Options.DefaultFilePath(wd
With Dialogs(wdDialogInsertPict
.Show
End With
'Change the default filepath back to the original default
Options.DefaultFilePath(wd
I already tried substituting "pp.." for "wd..." but no such luck.
I also found online the following snippet which does display an insert picture dialog (pointing to the default "my pictures" location) in PPT 2007, but it was clearly coded for legacy versions.
Application.CommandBars("M
I'd be happy to use this if I can control where it points.
Any suggestions?
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
versatilebb,
With apologies to the source:
http://officeone.mvps.org/vba/display_file_open_common_dialog.html
The above works fine ... for example place it in a code module on it's own and then you don't need to doi much other than call it when needed and take the string value which is the file(s) list in the collectioon S.
chris_bottomley
With apologies to the source:
http://officeone.mvps.org/vba/display_file_open_common_dialog.html
The above works fine ... for example place it in a code module on it's own and then you don't need to doi much other than call it when needed and take the string value which is the file(s) list in the collectioon S.
chris_bottomley
ASKER
This is my kind of solution: simple but effective. This does everything I need it to do
ASKER
Thanks for the code, Chris, but all I really needed was Anothony2oo5's simpler solution. I may look into this if I ever need to do anything fancier.
Thanks, Anthony.
Thanks, Anthony.
With appropriate editing to point to your directory and file types then ...
Regards,
chris_bottomley
Open in new window