Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2011, 08:22 AM
tinfanide tinfanide is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 64bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Expert
Excel VBA: How to add a reference to Microsoft Word Object Library?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Excel VBA: How to add a reference to Microsoft Word Object Library?


I mean by writing codes on Macro in Excel,
not by going to Tool -> Reference -> ...
Coz I don't want my users to do it themselves...
Reply With Quote
  #2  
Old 12-10-2011, 04:49 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 32bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

This can be done by code, but why would they need to do it themselves in the first place?
Reply With Quote
  #3  
Old 12-10-2011, 08:16 PM
tinfanide tinfanide is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 64bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Expert
Excel VBA: How to add a reference to Microsoft Word Object Library?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Because everytime the users start the application, the MS Word Object Library needs to be re-ticked again. (in my case)
Reply With Quote
  #4  
Old 12-11-2011, 02:26 AM
macropod's Avatar
macropod macropod is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 64bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi tinfanide,

Once you've set the reference for the macros in a particular file, it should stay set for that file.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-11-2011, 04:52 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 32bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

If your users have an earlier version of MS Word than the person that last saved the application, then the MS Word reference will become broken. If this is the scenario then you should develop your application using early binding, but then convert it to late binding and remove the MS Word reference entirely before it is deployed. That way the reference will not be an issue. You must, of course, ensure that the code which automates MS Word is compatible for all versions in use by the end users.
Reply With Quote
  #6  
Old 12-11-2011, 04:57 AM
macropod's Avatar
macropod macropod is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 64bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

To that end, it's generally best to develop code on the earliest version for which support is required and to test it on the latest version for which support is required.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 12-12-2011, 03:46 AM
tinfanide tinfanide is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 64bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Expert
Excel VBA: How to add a reference to Microsoft Word Object Library?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Thanks for the binding reminder.
It seems to work without the reference.
In Excel VBA:
Code:
Sub lateBinding()

' no need to set reference to MS Word Object Library
Dim wrdApp As Object
Set wrdApp = CreateObject("Word.Application")
Dim wrdDoc As Object
Set wrdDoc = wrdApp.Documents.Add

wrdApp.Visible = True
wrdDoc.Sections(1).Range.Delete

With wrdDoc
    .Paragraphs.Add
    .Paragraphs(1).Range.Text = "Late Binding: no need to set reference to MS Word Object Library"
End With

Set wrdDoc = Nothing
Set wrdApp = Nothing

End Sub
Reply With Quote
  #8  
Old 12-12-2011, 05:21 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline Excel VBA: How to add a reference to Microsoft Word Object Library? Windows 7 32bit Excel VBA: How to add a reference to Microsoft Word Object Library? Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Quote:
Originally Posted by tinfanide View Post
Thanks for the binding reminder.
It seems to work without the reference.
Yes, exactly.

There are several disadvantages to using late binding: slightly slower performance and loss of intellisense. The loss of intellisense is quite an impediment during the development phase, which is why I recommend that you develop the project using early binding and then convert to late binding just before final testing and deployment.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
option Paste special...as 'Microsoft Excel Chart Object' NOT available Intruder PowerPoint 0 12-24-2010 06:28 AM
Problem: object library invalid or contains references to object definitions aligahk06 Office 0 08-19-2010 12:29 PM
Problem with my microsoft word com object in c# web application Naresh_1210 Word VBA 0 03-11-2010 12:26 AM
Inserting citations using the reference function in Microsoft Word 2007? aeyara Word 0 09-28-2009 05:33 PM
Access Object library 10 Gyto Office 0 10-09-2008 09:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft