Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 12-22-2011, 08:09 AM
tinfanide tinfanide is offline Let Office Object Library 14.0 work in Office 2007 Windows 7 64bit Let Office Object Library 14.0 work in Office 2007 Office 2010 32bit
Expert
Let Office Object Library 14.0 work in Office 2007
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Late Binding in Word VBA?

Code:
Sub test()

Dim wrdApp As Object
Set wrdApp = CreateObject("Word.Application")
Dim wrdDoc As Object
Set wrdDoc = wrdApp.Documents.Add
wrdApp.Visible = True

Dim wrdTbl As Object
Set wrdTbl = wrdDoc.Tables.Add(Range:=wrdDoc.Range, _
NumRows:=ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 2, _
NumColumns:=4)

With wrdTbl

    .Borders(wdBorderTop).LineStyle = wdLineStyleSingle
    .Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
    .Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
    .Borders(wdBorderRight).LineStyle = wdLineStyleSingle
    .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
    .Borders(wdBorderVertical).LineStyle = wdLineStyleSingle
    
End With

Set wrdApp = Nothing
Set wrdDoc = Nothing
Set wrdTbl = Nothing

End Sub
Can anyone give me the idea of adding borders to a late-bound word table? I can do it in early binding, but not in late binding...
In the above case, the table is created but borders not added. It reports, "Applicaton defined or object defined error".

Code:
Dim wrdTbl = Word.Table
Set wrdTbl = wrdDoc.Tables.Add(Range:=wrdDoc.Range, _
NumRows:=ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 2, _
NumColumns:=4)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Let Office Object Library 14.0 work in Office 2007 Excel VBA: How to add a reference to Microsoft Word Object Library? tinfanide Excel Programming 7 12-12-2011 05:21 AM
Problem: object library invalid or contains references to object definitions aligahk06 Office 0 08-19-2010 12:29 PM
Using Office Premium 2007 Trial with Already Installed Office Home and Student 2007 SME Office 1 10-07-2009 06:51 AM
Let Office Object Library 14.0 work in Office 2007 Office 2007 Professional shipped from US, will it work on UK Windows PC's ? OfficeDude Office 3 08-16-2009 02:11 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 05:40 AM.


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