![]() |
#8
|
|||
|
|||
![]() Quote:
Code:
Dim wrdTbl As Table Dim wrdRng As Range please see the comments below. When I need to not set reference to any object library so that users can use my macro any version of the Office applications (in my case, I write the macro in 2010, but want my users to run in 2007 and I don't want to start everything in Word Object Library 12.0) Code:
Sub setTableBorders() Dim wrdApp As Object Set wrdApp = CreateObject("Word.Application") Dim wrdDoc As Object Set wrdDoc = wrdApp.documents.Add wrdApp.Visible = True ' Dim wrdTbl As Table doesn't work in Excel VBA Dim wrdTbl As Object Set wrdTbl = wrdDoc.Tables.Add(Range:=wrdDoc.Range, _ NumRows:=4, _ NumColumns:=1) With wrdTbl For r = 1 To 4 .Cell(r, 1).Range.Text = ActiveSheet.Cells(r, 1).Value Next r ' Starting from this line, it does not work ' Application-defined or Object-defined error .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 End Sub Book1.xlsm Please see the attachment. |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |
![]() |
OfficeDude | Office | 3 | 08-16-2009 02:11 PM |
Access Object library 10 | Gyto | Office | 0 | 10-09-2008 09:04 AM |