[resolved] macro actionsettings powerpoint 2007
What i'm trying to do:
I create a new index document, search a folder for files, add those files to my index and link them back to their respective paths (to open the files)
This worked fine in 2003, however with 2007 it stops somewhere in the code (as shown below)
Code:
With objShapes(objShapes.Count).TextFrame.WordWrap = msoFalse
.Tags.Add "Path", list(1, i)
With .ActionSettings.Item(ppMouseClick) <-- stops here!
.Action = ppActionRunMacro
.Run = "OpenDocument"
.AnimateAction = True
End With
End With
Any suggestions? :ehh:
Re: macro actionsettings powerpoint 2007
I believe the problem is that your first 'with' addresses the wordwrap property of the Textframe, then your second 'with' addresses the action settings, but it needs to refer to the shape, not the wordwrap property.
Try this:
vb Code:
With objShapes(objShapes.Count)
.TextFrame.WordWrap = msoFalse
.Tags.Add "Path", list(1, i)
With .ActionSettings.Item(ppMouseClick) <-- stops here!
.Action = ppActionRunMacro
.Run = "OpenDocument"
.AnimateAction = True
End With
End With
Re: macro actionsettings powerpoint 2007
call me stupid, but I don't see any difference? :confused:
Re: macro actionsettings powerpoint 2007
Quote:
Originally Posted by
Dragolin
call me stupid, but I don't see any difference? :confused:
Yours:
Code:
With objShapes(objShapes.Count).TextFrame.WordWrap = msoFalse
You are addressing the 'WordWrap' property.
Mine (NOTE - broken onto 2 lines):
Code:
With objShapes(objShapes.Count)
.TextFrame.WordWrap = msoFalse
I am addressing the shape - objShapes(objShapes.Count)
When you get to the second 'With' statement, yours effectively resolves to:
Code:
objShapes(objShapes.Count).TextFrame.WordWrap.ActionSettings.Item(ppMouseClick)
My code resolves to:
Code:
objShapes(objShapes.Count).ActionSettings.Item(ppMouseClick)
Re: macro actionsettings powerpoint 2007
ok, thanks for pointing that out
however that was a bad paste on my side, the actual code does have the wordwrap on a seperate line ...
so there must be another problem :)
Re: macro actionsettings powerpoint 2007
Quote:
however that was a bad paste on my side, the actual code does have the wordwrap on a seperate line ...
Can you upload your file for a faster resolution?
Re: macro actionsettings powerpoint 2007
Quote:
Originally Posted by
Dragolin
ok, thanks for pointing that out
however that was a bad paste on my side, the actual code does have the wordwrap on a seperate line ...
so there must be another problem :)
Can't say what the problem is, the code works properly for me (after making slight adjustments to substitute absolute objects for your variables). The only things I can suggest, is be sure that 'objShapes(objShapes.Count)' is a valid object, otherwise, you're going to have to upload a copy of the file you're using as koolsid suggested.
1 Attachment(s)
Re: macro actionsettings powerpoint 2007
This is the code on which I get an error
So the first macro calls the create-index macro in 'step 2' and a similar one in 'step 3' where it fails as described in the previous post
Any help is GREATLY appreciated! thx in advance! :thumb:
Re: macro actionsettings powerpoint 2007
Hi Dragolin
Can you zip up your ppt and upload it?
Re: macro actionsettings powerpoint 2007
I'm afraid that's impossible, due to company internal information + you would need a specific folder structure the login tool scans for these documents
If you need any additional info, I'll try to post it as well :)
Re: macro actionsettings powerpoint 2007
I tried to go through the code you posted, but there were too many variables that I don't know what their value would be.
The base code works for me. One thing I would suggest is instead of
vb Code:
With objShapes(objShapes.Count)
you set a variable to the shape that is created in the line directly before that and use that in your 'with' statement. Something like:
vb Code:
Dim objShape As PowerPoint.Shape
Set objShape = objShapes.AddPicture(DefaultLocation & "EggCartons.gif", msoFalse, msoCTrue, 650, 162 + (NrSelectedItems * 30) - (objPresentation.Slides.Count - 1) * 300, 25, 25)
With objShape
...
Edit - I think I might know what is going wrong - You set an object variable to the shapes on the slide (objShapes), then you add a shape without updating that variable. I believe it still only contains the shapes that existed when you set the variable. Using the above code should fix the problem if that is what it is.
Edit #2 - Nevermind, the objShapes variable does update when adding shapes.
Re: macro actionsettings powerpoint 2007
any idea's as I'm still stuck with this problem :)
Re: macro actionsettings powerpoint 2007
Well you haven't given much to work upon so here is my last effort towards the problem...
Try this..
Tell me what happens?
Code:
With objShapes(objShapes.Count)
.TextFrame.WordWrap = msoFalse
.Tags.Add "Path", List(1, i)
With .ActionSettings(ppMouseClick) '<~~ Change this
.Action = ppActionRunMacro
.Run = "OpenDocument"
.AnimateAction = True
End With
End With
Re: macro actionsettings powerpoint 2007
with or without ".item" gives the same result, I tried that already ...
Re: macro actionsettings powerpoint 2007
Your code is correct to add the action settings to a shape. Try running a test with just that code (select a shape, and run this code), and tell me if it works properly:
vb Code:
Sub test()
With ActivePresentation.Windows(1).Selection.ShapeRange(1)
'.Tags.Add "Path", List(1, i) ' NOTE - removed for testing
With .ActionSettings.Item(ppMouseClick) '<-- stops here!
.Action = ppActionRunMacro
.Run = "OpenDocument"
.AnimateAction = True
End With
End With
End Sub
If this works, then the problem is with another part of the code.
And I still think you'd be better off using a variable whenever you add a shape as I suggested, instead of using 'objShapes(objShapes.Count)'.
Re: macro actionsettings powerpoint 2007
the solution was simple yet hard to find:
we were using a GetObject(Template) to call another presentation and now we fixed it using Application.Presentations.Open(FileName:=Template, withwindow:=False)
so it stopped on the code I showed you above, but that code was actually perfectly fine :)