I figured it out .. and it was so easy:
etc.
Quote:
Hi guys
>
I got the following code:
>
-------------------------------------------------------
>
Dim Word As New Microsoft.Office.Interop.Word.Application
Dim Document As Microsoft.Office.Interop.Word.Document
Document = Word.Documents.Open(Filename)
>
>
Dim myStoryRange As Microsoft.Office.Interop.Word.Range
For Each myStoryRange In Document.StoryRanges
With myStoryRange.Find
.Text = "<CHANGES>"
.Replacement.Text = "Here is the changes"
.Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindCon tinue
>
.Execute(Replace:=Microsoft.Office.Interop.Word.Wd Replace.wdReplaceAll)
End With
Next myStoryRange
>
-------------------------------------------------------
>
>
.. which opens a Word file, locates <CHANGESand replaces it with "Here
is the changes". It works just fine, but instead of just replacing with
text, I would like to replace it with a table like this:
>
>
-------------------------------------------------------
>
With Document
>
Dim tableRange As Object
tableRange = Document.Range()
>
.Tables.Add(2, 2)
.Tables.Item(1).Range.Font.Size = 10
.Tables.Item(1).Range.Font.Name = "Verdana"
.Tables.Item(1).Range.Font.Bold = False
.Tables.Item(1).Style = "table grid"
>
.Tables.Item(1).Cell(1, 1).Range.Text = "Hey"
.Tables.Item(1).Cell(1, 1).Column.Width = 100
.Tables.Item(1).Cell(1, 1).Range.Font.Bold = True
.Tables.Item(1).Cell(1, 2).Range.Text = "Ho"
.Tables.Item(1).Cell(1, 2).Column.Width = 100
.Tables.Item(1).Cell(1, 2).Range.Font.Bold = True
>
>
End With
>
-------------------------------------------------------
>
>
Could anyone please give me hint on how to use a table as replacement
for the located text?
>
Regards Søren