Re: CreateObject vs New
From: dR <onlyng_at_gmail.com>
Date: Sun, 2 Mar 2008 05:50:59 -0800 (PST) On Feb 29, 4:52 pm, Steve Rindsberg <ab..._at_localhost.com> wrote: > In article <ce89a735-0c52-4171-9ac5-50ddab7f1..._at_i29g2000prf.googlegroups.com>, > > Dr wrote: > > Since PowerPoint is a single instance application, what is the > > difference between: > > > Set oPPApp = New PowerPoint.Application > > > and > > > Set oPPApp = CreateObject("PowerPoint.Application") > > One fires off a new instance of PowerPoint and gives you a reference to it or > gives you a reference to the already-running instance if one exists. > > The other gives you a reference to the already-running instance of PPT if one > exists or fires off a new instance and gives you reference to it. > > IOW, no real difference. > > ----------------------------------------- > Steve Rindsberg, PPT MVP > PPT FAQ: www.pptfaq.com > PPTools: www.pptools.com > ================================================ If there is no real difference, and a new instance will be started as necessary,is there any sense in testing for an existing instance? I saw many users using code like this: On Error Resume Next Set oPPApp = GetObject(, "PowerPoint.Application") On Error GoTo 0 If oPPApp Is Nothing Then Set oPPApp = New PowerPoint.Application Else '** Do nothing. PowerPoint already exists. End If Is there any purpose to all this?
Thanks
|
Click to report inappropriate content