Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Deanna Earley Newsgroups: comp.lang.basic.visual.misc Subject: Re: 3 questions from an new oldbie Date: Wed, 30 Nov 2011 09:23:51 +0000 Organization: Aioe.org NNTP Server Lines: 39 Message-ID: References: <7a6380d8-b02a-4ece-a2fd-f934a00e9145@h3g2000yqa.googlegroups.com> NNTP-Posting-Host: rjApkXnSOjrT83QpZ8fKqg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.basic.visual.misc:534 On 29/11/2011 20:32, John L. wrote: > I am trying to instanciate a Visual Basic Class Module called > "myClass" in a Word 2003 VB macro. I have tried the following: > > dim a As myClass > Set a = CreateObject("Word.Application.myClass") > & > Set a = CreateObject("Project.myClass") > & > Set a = CreateObject("Word.myClass") > > All failed with the same run-time error (429 : ActiveX component can't > create object). What is the correct invocation? If the class is in the VBA project, then CreateObject is not suitable as that goes to registered COM objects. You want simply: Set a = New myClass > Is the object saved in the document once created, or destroyed once > the variable is out of scope? The class is saved, the instance of the object will "disappear" as soon as it's no longer referenced or the code/project exits. > How do I trap an error returned if GetObject doesn't find the > object? On Error .... -- Dee Earley (dee.earley@icode.co.uk) i-Catcher Development Team http://www.icode.co.uk/icatcher/ iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.)