D
David Clark
Hi
I have a Lotus application that creates a Word 2003 document via OLE.
It's almost complete, much to my surprise as I don't really know what
I'm doing (as will become apparent) and I've only got this far by
finding code snippets, recording macros and using the object browser.
Anyway I just have 2 remaining issues, the first is more important
than the second.
1. I need to insert a tick symbol in a table cell. I found that I need
use the insertsymbol method and that needs to be on a selection but
how do I get that 'selection'? My function that inserts text in a
call uses a range. Here's my failing code - the errors I see vary
from 'insertsymbol is not a property' (yes, that I know) to something
about whatever I've tried the method on not being a simple selection.
Function addticktocell(table As Variant, rowNum As Integer, colNum As
Integer) As Variant
Dim cell As Variant
Dim lastParagraph As Variant
Dim newRangeStart As Long
Dim selection As Variant
Set cell = GetTableCell(table, rowNum, colNum)
Set lastParagraph = Nothing
If Not cell Is Nothing Then
Set lastParagraph =
cell.Range.Paragraphs(cell.Range.Paragraphs.Count).Range
lastparagraph.select
Call lastparagraph.select.insertSymbol("Wingdings 2", -4014, True)
'Call selection.insertSymbol("Wingdings 2", -4014, True)
newRangeStart = lastParagraph.End-1
Set lastParagraph =
cell.Range.Paragraphs(cell.Range.Paragraphs.Count).Range
Call lastParagraph.SetRange(newRangeStart, lastParagraph.End)
Call lastparagraph.select
'Call lastparagraph.insertSymbol("Wingdings 2", -4014, True)
End If
End Function
2. I'd like to be able to create a table inside the cell of an
existing table but I can't see how to navigate to the cell. My current
createtable works at the document level....
Function CreateTable(doc As Variant, numRows As Integer, numCols As
Integer, pwidth) As Variant
Dim lastParagraph As Variant
Dim range As Variant
Dim table As Variant
Set lastParagraph = doc.Paragraphs(doc.Paragraphs.Count).Range
Set range = doc.Range(lastParagraph.Start, lastParagraph.End)
Set table = doc.Tables.Add(range, numRows, numCols)
table.PreferredWidthType = 2
table.PreferredWidth = pwidth
Set CreateTable = table
End Function
Any guidance gratefully received
I have a Lotus application that creates a Word 2003 document via OLE.
It's almost complete, much to my surprise as I don't really know what
I'm doing (as will become apparent) and I've only got this far by
finding code snippets, recording macros and using the object browser.
Anyway I just have 2 remaining issues, the first is more important
than the second.
1. I need to insert a tick symbol in a table cell. I found that I need
use the insertsymbol method and that needs to be on a selection but
how do I get that 'selection'? My function that inserts text in a
call uses a range. Here's my failing code - the errors I see vary
from 'insertsymbol is not a property' (yes, that I know) to something
about whatever I've tried the method on not being a simple selection.
Function addticktocell(table As Variant, rowNum As Integer, colNum As
Integer) As Variant
Dim cell As Variant
Dim lastParagraph As Variant
Dim newRangeStart As Long
Dim selection As Variant
Set cell = GetTableCell(table, rowNum, colNum)
Set lastParagraph = Nothing
If Not cell Is Nothing Then
Set lastParagraph =
cell.Range.Paragraphs(cell.Range.Paragraphs.Count).Range
lastparagraph.select
Call lastparagraph.select.insertSymbol("Wingdings 2", -4014, True)
'Call selection.insertSymbol("Wingdings 2", -4014, True)
newRangeStart = lastParagraph.End-1
Set lastParagraph =
cell.Range.Paragraphs(cell.Range.Paragraphs.Count).Range
Call lastParagraph.SetRange(newRangeStart, lastParagraph.End)
Call lastparagraph.select
'Call lastparagraph.insertSymbol("Wingdings 2", -4014, True)
End If
End Function
2. I'd like to be able to create a table inside the cell of an
existing table but I can't see how to navigate to the cell. My current
createtable works at the document level....
Function CreateTable(doc As Variant, numRows As Integer, numCols As
Integer, pwidth) As Variant
Dim lastParagraph As Variant
Dim range As Variant
Dim table As Variant
Set lastParagraph = doc.Paragraphs(doc.Paragraphs.Count).Range
Set range = doc.Range(lastParagraph.Start, lastParagraph.End)
Set table = doc.Tables.Add(range, numRows, numCols)
table.PreferredWidthType = 2
table.PreferredWidth = pwidth
Set CreateTable = table
End Function
Any guidance gratefully received