B
Bill Coan
NOTE: This was posted earlier to vsnet.vstools.office under a different
subject line but received no response.
I'm having a problem automating Word's Find object from a .NET application,
using late binding.
If I use early binding, my code runs fine on most systems, but it is
vulnerable to a known bug explained here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;292744
The workaround to the bug is to use late binding instead of early binding,
but late binding has a problem of its own. The problem strikes me as a
generic automation problem and not a .NET interop problem.
I started with the following early-bound code:
Dim rngSource as Word.Range = wdDoc.Range.Paragraphs.Item(1).Range
Dim rngDestination as Word.Range = wdDoc.Range.Paragraphs.Item(2).Range
rngDestination.FormattedText = rngSource.FormattedText
After reading the above-referenced article, I switched to late-bound code as
follows:
Dim rngSource as Object = wdDoc.Range.Paragraphs.Item(1).Range
Dim rngDestination as Object = wdDoc.Range.Paragraphs.Item(2).Range
rngDestination.FormattedText = rngSource.FormattedText
NOTE: wdDoc is declared and instantiated elsewhere in my code and is NOT the
source of the problem.
When the late-bound code runs, I get the following error:
".FormattedText is not a by reference property"
Can anyone suggest how to access the .FormattedText property (and other "not
by reference" properties) of a late-bound object? Within .NET, is there some
way to use Reflection to access such properties?
Bill Coan
(e-mail address removed)
subject line but received no response.
I'm having a problem automating Word's Find object from a .NET application,
using late binding.
If I use early binding, my code runs fine on most systems, but it is
vulnerable to a known bug explained here:
http://support.microsoft.com/default.aspx?scid=kb;en-us;292744
The workaround to the bug is to use late binding instead of early binding,
but late binding has a problem of its own. The problem strikes me as a
generic automation problem and not a .NET interop problem.
I started with the following early-bound code:
Dim rngSource as Word.Range = wdDoc.Range.Paragraphs.Item(1).Range
Dim rngDestination as Word.Range = wdDoc.Range.Paragraphs.Item(2).Range
rngDestination.FormattedText = rngSource.FormattedText
After reading the above-referenced article, I switched to late-bound code as
follows:
Dim rngSource as Object = wdDoc.Range.Paragraphs.Item(1).Range
Dim rngDestination as Object = wdDoc.Range.Paragraphs.Item(2).Range
rngDestination.FormattedText = rngSource.FormattedText
NOTE: wdDoc is declared and instantiated elsewhere in my code and is NOT the
source of the problem.
When the late-bound code runs, I get the following error:
".FormattedText is not a by reference property"
Can anyone suggest how to access the .FormattedText property (and other "not
by reference" properties) of a late-bound object? Within .NET, is there some
way to use Reflection to access such properties?
Bill Coan
(e-mail address removed)