Macro for use in all presentations?

V

Victor Delta

Hi

Can anyone please tell me whether it is possible to record a macro in
PowerPoint which is available for use in any presentation (rather like
recording a macro for Excel in personal.xls).

I can't find any documentation on this although I'm sure it must be
possible.

Indeed I thought I might have found a way to do it by saving a file with a
macro in it as a PowerPoint add-in but, even with the add-in subsequently
selected, the macros seems to have disappeared ever since the relevant ppt
file was closed.

TIA

V
 
L

Lucy Thomson

Hi Victor

This isn't my area so I won't be able to help with follow up questions, but
this article should get you started:
Create an ADD-IN with TOOLBARS that run macros
http://www.pptfaq.com/FAQ00031.htm

Any questions, post back including your version and code, and I'm sure one
of the coders will jump in to help :)

Lucy
 
D

David Marcovitz

You are correct that you need an add-in. An add-in, once installed, will
work on all presentations on a particular computer. Get more information
here:

Create an ADD-IN with TOOLBARS that run macros
http://www.pptfaq.com/FAQ00031.htm


There are lots of tricks with setting security levels that you need to
pay attention to.

--David
 
M

Michael Koerner

V

Victor Delta

Steve Rindsberg said:
You're on the right track; following the link that David posted will take
you
further along it. ;-)

To explain what you're seeing though, macros in an add-in don't appear in
the
Tools, Macros list. Your add-in has to provide a user interface for
accessing the macros ... by adding menu commands or creating a toolbar or
the
like.

Many thanks for all the help. What I'm now trying to do is create a macro
that will open the 'insert picture from file' dialogue box and then set the
folder to say C:\My Pictures, but using the macro recorder hasn't been a
great success.

Can anyone help please?

Thanks,

V

PS I tried using some of the techniques on your website for doing this but
they didn't work for me, hence this method...
 
V

Victor Delta

Steve Rindsberg said:
I don't think you can do exactly that, but you can invoke a file dialog
box to get an image file and
then write code to insert the image selected. Here's a cobbled up example
from bits in the PPT 2003
help on FileDialog:

Sub Main()

'Declare a variable as a FileDialog object.
Dim fd As FileDialog

'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)

'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant

'Use a With...End With block to reference the FileDialog object.
With fd

'Add a filter that includes GIF and JPEG images and make it the
first item in the list.
.Filters.Add "Images", "*.gif; *.jpg; *.jpeg", 1

'Set the initial path to the C:\ drive.
.InitialFileName = "C:\"

'Use the Show method to display the File Picker dialog box and
return the user's action.
'The user pressed the action button.
If .Show = -1 Then

'Step through each string in the FileDialogSelectedItems
collection.
For Each vrtSelectedItem In .SelectedItems

'vrtSelectedItem is a String that contains the path of each
selected item.
'You can use any file I/O functions that you want to work
with this path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem

' So here you'd use e.g. code from
' Insert a picture at the correct size
' http://www.pptfaq.com/FAQ00329.htm
' to drop in and size the image

Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With

'Set the object variable to Nothing.
Set fd = Nothing

End Sub

Steve

Many thanks,

V
 
D

David H. Straayer

:
"...http://www.pptfaq.com/FAQ00031.htm...
There are lots of tricks with setting security levels that you need to pay
attention to."

No kidding! I've followed the instructions in the FAQ mentioned above.
It took a little adjusting for PowerPoint 2007 - I think that FAQ may have
been written for an earlier version.

Even after (temporarily) taking my macro protection down to the
not-recommended level, I still can't get the macro to run. My macro is not
rocket science: just trying to save a PDF of handouts. But the current
versions of PowerPont and Vist seem intent on thwarting every thing I try. :)

If someone can recommend a book I'd sure appreciate it.
 
D

David H. Straayer

: " Does the code not run at all or does it run but
not do what you want it to? Do you get error messages?"

The error message reads (unhelpfully): "The macro cannot be found or has
been disabled because of your security settings."
 
D

David H. Straayer

I got it running, finally. My error, a minor edit to a posted example, and a
useless error message.

I agree with your comment: " Once PPT gets it in mind that your code is EVIL
INCARNATE, it's liable to disable it."

The whole issue of protection against bad code seems to have gone over the
top.

It's working now, and thanks for the help! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top