PDA

View Full Version : Solved: Set a permanent reference to powerpoint



jmenche
03-29-2012, 05:54 PM
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?

:beerchug:

Bob Phillips
03-30-2012, 02:46 AM
What do you mean by setting a reference every time, and why do you have to?

Are you using early binding, e,g,


Dim PPT = PowerPoint.Application

Set PPT =New PowerPoint.Application

If so, you can change it to late-binding


Dim PPT As Object

Set PPT = CreateObject("PowerPoint.Application")

jmenche
03-30-2012, 02:57 AM
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.

Bob Phillips
03-30-2012, 04:41 AM
Probably, give it a try.

Kenneth Hobs
03-30-2012, 06:08 AM
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

jmenche
03-30-2012, 07:04 AM
Works fine now.

Thanks everybody!!!

jmenche
03-30-2012, 07:13 AM
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?

Bob Phillips
03-30-2012, 07:15 AM
Never, ever, Dim something as New, it is a very bad practice.

jmenche
03-30-2012, 07:24 AM
I may not understand but why not?

Thanks again.

For some reason, I want some dim sum now!

Bob Phillips
03-30-2012, 07:44 AM
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.

jmenche
03-30-2012, 09:52 AM
cool....thanks!