Results 1 to 16 of 16

Thread: [resolved] macro actionsettings powerpoint 2007

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    Lightbulb [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?
    Last edited by Dragolin; Nov 24th, 2009 at 07:25 AM.

  2. #2
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    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:
    1. With objShapes(objShapes.Count)
    2. .TextFrame.WordWrap = msoFalse
    3.  
    4. .Tags.Add "Path", list(1, i)
    5.  
    6. With .ActionSettings.Item(ppMouseClick)  <-- stops here!
    7. .Action = ppActionRunMacro
    8. .Run = "OpenDocument"
    9. .AnimateAction = True
    10. End With
    11.  
    12. End With

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    Re: macro actionsettings powerpoint 2007

    call me stupid, but I don't see any difference?

  4. #4
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    Re: macro actionsettings powerpoint 2007

    Quote Originally Posted by Dragolin View Post
    call me stupid, but I don't see any difference?
    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)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    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

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: macro actionsettings powerpoint 2007

    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?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    Re: macro actionsettings powerpoint 2007

    Quote Originally Posted by Dragolin View Post
    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.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    Post 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!
    Attached Files Attached Files

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: macro actionsettings powerpoint 2007

    Hi Dragolin

    Can you zip up your ppt and upload it?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    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

  11. #11
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    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:
    1. 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:
    1. Dim objShape As PowerPoint.Shape  
    2.     Set objShape = objShapes.AddPicture(DefaultLocation & "EggCartons.gif", msoFalse, msoCTrue, 650, 162 + (NrSelectedItems * 30) - (objPresentation.Slides.Count - 1) * 300, 25, 25)
    3. With objShape
    4. ...


    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.
    Last edited by MarkWalsh; Oct 7th, 2009 at 10:48 AM.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    Re: macro actionsettings powerpoint 2007

    any idea's as I'm still stuck with this problem

  13. #13
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    Re: macro actionsettings powerpoint 2007

    with or without ".item" gives the same result, I tried that already ...

  15. #15
    Addicted Member
    Join Date
    Jan 2009
    Posts
    183

    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:
    1. Sub test()
    2.     With ActivePresentation.Windows(1).Selection.ShapeRange(1)
    3.         '.Tags.Add "Path", List(1, i) ' NOTE - removed for testing
    4.        
    5.         With .ActionSettings.Item(ppMouseClick)  '<-- stops here!
    6. .Action = ppActionRunMacro
    7. .Run = "OpenDocument"
    8. .AnimateAction = True
    9. End With
    10.  
    11.  
    12.     End With
    13.  
    14. 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)'.
    Last edited by MarkWalsh; Oct 27th, 2009 at 08:16 AM.

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width