Re: Changing reference to Word in Excel project

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Tom Ogilvy (twogilvy_at_msn.com)
Date: 05/03/04


Date: Mon, 3 May 2004 10:38:22 -0400

tools=>Macros=>Security, select trust access to Visual Basic Project

http://support.microsoft.com/default.aspx?scid=kb;EN-US;282830
PRB: Programmatic Access to Office XP VBA Project Is Denied

However, your whole idea sounds flawed. The library doesn't actually
contain the code that will be executed I don't believe, so you would be
using a roadmap of Europe to find you way around the US as an analogy.

The usual solution to this problem is to use late binding for the release
version of the application.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;244167
INFO: Writing Automation Clients for Multiple Office Versions

http://support.microsoft.com/default.aspx?scid=kb;en-us;245115
INFO: Using Early Binding and Late Binding in Automation

http://support.microsoft.com/default.aspx?scid=kb;en-us;247579
INFO: Use DISPID Binding to Automate Office Applications Whenever Possible

-- 
Regards,
Tom Ogilvy
"Ed" <Ed_Millis@NOSPAM.Hotmail.com> wrote in message
news:OziJghRMEHA.3012@tk2msftngp13.phx.gbl...
> I have an Excel project which calls Word (hence posting to both NG).  It's
> created on a system running Windows/Office XP.  I've been having
difficulty
> running code which calls Word on Windows/Office 2000 machines.  I
discovered
> the reference to the Word library was for Word10 - XP - which does not
exist
> on a 2000 machine.  I got the bright idea of copying the Word9 reference
> from a 2000 machine onto my XP machine, and then setting the reference in
> the code which creates this workbook.  With the following code, I have two
> problems:
>
> Sub Change_Refs()
>
> ' Set reference to Word9 vs. Word10
> refWord9 = "C:\Program Files\Microsoft Office\Office10\MSWORD9.olb"
> refWord10 = "C:\Program Files\Microsoft Office\Office10\MSWORD.olb"
>
> ThisWorkbook.VBProject.References.Remove refWord10
> ThisWorkbook.VBProject.References.AddFromFile refWord9
>
> End Sub
>
> Problem 1:  The Remove line generates an error - "Object required"
> Problem 2:  I commented out the Remove line just to see what the code
would
> do on the Add line.  Another error - I'm not trusted to programmatically
> change the VB project.
>
> Any suggestions?
>
> Ed
>
>


Relevant Pages

  • Re: Changing reference to Word in Excel project
    ... select trust access to Visual Basic Project ... Programmatic Access to Office XP VBA Project Is Denied ... Writing Automation Clients for Multiple Office Versions ... Using Early Binding and Late Binding in Automation ...
    (microsoft.public.word.vba.general)
  • RE: Automating Word
    ... not use the following automation-Code (Early Binding) ... dim wdaApp as Word.Application ... set wdApp = New Word.Application ... > an automation error when he tries to start the process from Access. ...
    (microsoft.public.office.developer.automation)
  • Re: excel missing library
    ... Using Early Binding and Late Binding in Automation ... > Dim LesRefs As Object, i&, Msg$, Cpt&, Rep&, Mnq&, Chemin$, Nom$> ... > If Mnq> 0 Then ...
    (microsoft.public.excel.programming)
  • Re: Missing References
    ... Writing Automation Clients for Multiple Office Versions ... Using Early Binding and Late Binding in Automation ... While the Add-In performs without problems on ... If I reselect the Word 9 or 10 Reference on ...
    (microsoft.public.excel.programming)