E
Elaine B.
VB.NET and automation of Word XP. I am doing Find/Replace
on a large document. Because of the nature of how this
document is built, I want to limit the Find/Replace to the
last two pages of a document. Someone kindly gave me this
code:
'Dim iP As Integer
'Dim sP As String
'Dim rR As Range
'rR = Selection.Range
'iP = ActiveDocument.ComputeStatistics(wdStatisticPages)
'sP = Trim(Str(iP - 1))
'Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext,
Name:=sP
'rR.Start = Selection.Start
'rR.End = ActiveDocument.Content.End
'rR.Select()
'With rR.Find
' .Text = "i"
' .Replacement.Text = "#"
' .Wrap = wdFindStop
' rR.Find.Execute(Replace:=wdReplaceAll)
'End With
The problem I am having is that this is written to run in
VBA behind a Word doc ("Active Document", "Selection",
etc). So I thought I could just tweak it to run in VB.NET
using a Word document object. The Selection object is
where I am having problems. I think I need to create a
Selection object (dim oSelection as selection) and then
set that object variable equal something. I dont want the
whole document, do I? Or do I? And if so, how do I do that?
oDoc is my Word doc object. It has no .Selection property.
So I am confused on how to get this code to run in VB.NET.
Can anyone advise?
on a large document. Because of the nature of how this
document is built, I want to limit the Find/Replace to the
last two pages of a document. Someone kindly gave me this
code:
'Dim iP As Integer
'Dim sP As String
'Dim rR As Range
'rR = Selection.Range
'iP = ActiveDocument.ComputeStatistics(wdStatisticPages)
'sP = Trim(Str(iP - 1))
'Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext,
Name:=sP
'rR.Start = Selection.Start
'rR.End = ActiveDocument.Content.End
'rR.Select()
'With rR.Find
' .Text = "i"
' .Replacement.Text = "#"
' .Wrap = wdFindStop
' rR.Find.Execute(Replace:=wdReplaceAll)
'End With
The problem I am having is that this is written to run in
VBA behind a Word doc ("Active Document", "Selection",
etc). So I thought I could just tweak it to run in VB.NET
using a Word document object. The Selection object is
where I am having problems. I think I need to create a
Selection object (dim oSelection as selection) and then
set that object variable equal something. I dont want the
whole document, do I? Or do I? And if so, how do I do that?
oDoc is my Word doc object. It has no .Selection property.
So I am confused on how to get this code to run in VB.NET.
Can anyone advise?