muttleee
02-02-2006, 03:11 AM
Hiyas, http://vbaexpress.com/forum/images/smilies/039.gif
I've got some code that picks up values from a notes document and prints them in a table on a Word document. However I don't want the table borders to print but I can't seem to get rid of them.
Here's the gist of the code that sets up my table:
Sub Initialize
Dim session As New NotesSession
'dim and set remaining variables etc
'set up table in Word document
Set wdApp = CreateObject("Word.Application")
Set worddocument = wdApp.Documents.Add()
wdApp.visible = True
With wdApp
.selection.pagesetup.Orientation = wdOrientPortrait
'set up paragraph, font etc
.selection.typetext("Corporate Planning Targets")
'set up table dimensions
Set TableObj = .selection.Tables.Add(wdApp.Selection.Range, 22, 7)
TableObj.Columns(1).Width = 100
'...etc
TableObj.cell(1,1).select
.selection.font.bold=True
.selection.typetext("Period:")
'...etc
End With
'print footer here
Set session = Nothing
Set db = Nothing
Set TableObj = Nothing
Set wdApp = Nothing
Set worddocument = Nothing
End Sub
To try to get rid of borders I tried this, immediately after the "Set TableObj = .selection.Tables.Add(wdApp.Selection.Range, 22, 7)" line:
With TableObj
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With This prints out the table ok but then tells me that the requested member of the collection doesn't exist. I then tried calling a Subroutine that I round online somewhere called FixTableBorders. It was originally written to set borders to a certain width but I tweaked it to make the linestyle 'none'. To no avail, unfortunately:
Sub FixTableBorders()
'Forall objTable In worddocument.Tables - gives 'Variant does not contain an object' error
Forall objTable In wordDocument.Sections(1).Tables 'no error but still doesn't work
objTable = ActiveDocument.Tables(0)
With objTable
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleNone
End With
'...etc
End With
End Forall
End SubI'm sure this should be straightforward but I just can't seem to get anything to work. Any help would be gratefully appreciated! http://vbaexpress.com/forum/images/smilies/pray2.gif
Thanks in advance!
I've got some code that picks up values from a notes document and prints them in a table on a Word document. However I don't want the table borders to print but I can't seem to get rid of them.
Here's the gist of the code that sets up my table:
Sub Initialize
Dim session As New NotesSession
'dim and set remaining variables etc
'set up table in Word document
Set wdApp = CreateObject("Word.Application")
Set worddocument = wdApp.Documents.Add()
wdApp.visible = True
With wdApp
.selection.pagesetup.Orientation = wdOrientPortrait
'set up paragraph, font etc
.selection.typetext("Corporate Planning Targets")
'set up table dimensions
Set TableObj = .selection.Tables.Add(wdApp.Selection.Range, 22, 7)
TableObj.Columns(1).Width = 100
'...etc
TableObj.cell(1,1).select
.selection.font.bold=True
.selection.typetext("Period:")
'...etc
End With
'print footer here
Set session = Nothing
Set db = Nothing
Set TableObj = Nothing
Set wdApp = Nothing
Set worddocument = Nothing
End Sub
To try to get rid of borders I tried this, immediately after the "Set TableObj = .selection.Tables.Add(wdApp.Selection.Range, 22, 7)" line:
With TableObj
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With This prints out the table ok but then tells me that the requested member of the collection doesn't exist. I then tried calling a Subroutine that I round online somewhere called FixTableBorders. It was originally written to set borders to a certain width but I tweaked it to make the linestyle 'none'. To no avail, unfortunately:
Sub FixTableBorders()
'Forall objTable In worddocument.Tables - gives 'Variant does not contain an object' error
Forall objTable In wordDocument.Sections(1).Tables 'no error but still doesn't work
objTable = ActiveDocument.Tables(0)
With objTable
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleNone
End With
'...etc
End With
End Forall
End SubI'm sure this should be straightforward but I just can't seem to get anything to work. Any help would be gratefully appreciated! http://vbaexpress.com/forum/images/smilies/pray2.gif
Thanks in advance!