Consulting

Results 1 to 11 of 11

Thread: Solved: Set a permanent reference to powerpoint

  1. #1

    Solved: Set a permanent reference to powerpoint

    Howdy,

    I have a macro that exports charts to powerpoint. I have to set a reference to Powerpoint every time. It's not just annoying to me but it precludes me from sending this macro to non-vba colleagues.

    Is there any way to set a permanent reference to powerpoint?


  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What do you mean by setting a reference every time, and why do you have to?

    Are you using early binding, e,g,

    [vba]
    Dim PPT = PowerPoint.Application

    Set PPT =New PowerPoint.Application[/vba]

    If so, you can change it to late-binding

    [vba]
    Dim PPT As Object

    Set PPT = CreateObject("PowerPoint.Application")[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    I'm talking about a reference to the object library under Tools/References. Would the binding thing help me out? The only binding that i know of is fiber :-).

    Thanks for the help.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Probably, give it a try.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Late binding means that Intellisense will not work for that object. This is why some will develop code by early binding and then put the project out as late bound. Constants for the object will need to be dimmed and set or just use the numerical value. For the object itself, the method that xld gave is what you need.

    For binding see: http://support.microsoft.com/kb/245115

  6. #6
    Works fine now.

    Thanks everybody!!!

  7. #7
    This is jogging my memory. If I Dim something as a New Application, would I still need to set the variable? Basically, would it be one step instead of two?

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Never, ever, Dim something as New, it is a very bad practice.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    I may not understand but why not?

    Thanks again.

    For some reason, I want some dim sum now!

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Curse you, I want dim sum now also.

    DIMming a variable with New is what is called an auto-instancing variable. But spookily, the Dim statement does not create the object is not created when it is dimmed, but rather when it is first created within the code. This means that you lose all control over the existence of that object, so for the sake of one line of code you have things happening under the hood that you might not expect and therefore may react wrongly/inappropriately to.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  11. #11
    cool....thanks!

Posting Permissions

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