Hello All,
I am having trouble manipulating cell properties (Background Color, Cell Borders)in MS Word. I have no trouble merging cells, inputing text to cells creating multiple tables. Also i have tried many of the VB example found online and on msdn online. Has anyone had any success with this, does anyone have any script samples? (Yes i have searched the forums and the sandbox)
Thanks in advance
Peter Marcantonio
(Lost in OLE)
Subject: Lotuscript and MS Word - Manipulating Cell properties
I haven’t got a clue – but I’d like to know how many word processors you’re using these days ;o)
Subject: RE: Lotuscript and MS Word - Manipulating Cell properties
Hello Stan,
At the moment because the place where i work is slow to buy a good reporting tool i’m stuck creating reports with Excell, Lotus 123, WordPerfect and Word.
Subject: Lotuscript and MS Word - Manipulating Cell properties
I’m no wiz at this, but using Tools-Macro and the VBScript editor, you can record macros and end up with something like this:
Sub Macro1()
’
’ Macro1 Macro
’ Macro recorded 03/24/2005 by Doug Jamieson
’
CommandBars("Clipboard").Visible = False
Selection.TypeParagraph
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:= _
5, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorSeaGreen
End With
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderHorizontal)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderVertical)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = wdColorAutomatic
End With
End Sub
Subject: Then if you step into the code in the VB Debugger, you can mouse hover over…
the constants like wdColorSeaGreen and find the numeric equivalents for them.
Subject: RE: Lotuscript and MS Word - Manipulating Cell properties
Hello Doug,
I’ll give it a run again, last time i tried that it didn’t mesh too well. Translated constants were not working that well. Did you have any success with this technique?
Thanks
Subject: RE: Lotuscript and MS Word - Manipulating Cell properties
The real problem is in getting the absolute syntax for all of the calls you need to make. Since we don’t have access to the “paramname := value” syntax in LotusScript, we need to find out what the “natural order” of the parameters are, so:
MSObject.PropertyChanger Apple:=msMacintosh, Flower:=msRose
may need to translate to:
Call MSObject.PropertyChanger(3,-4197)
In the OLE/COM FAQ, there’s a link to an interesting post by Brandt Fundak that covers the syntax problem and what you can do about it.
Subject: RE: Lotuscript and MS Word - Manipulating Cell properties
Once again Stan thanks. I should be able to write a book by the time i’m done with this project.