471,616 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

Word Automation Error: ".FormattedText is not a by reference property"

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...b;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
bi******@wordsite.com
Nov 21 '05 #1
4 3814
Hi,

have you tried:

x = rngSource.FormattedText
rngDestination.FormattedText = x

Maybe this helps.
Greets, Helmut Obertanner
"Bill Coan" <bi******@wordsite.com> schrieb im Newsbeitrag
news:OL**************@TK2MSFTNGP15.phx.gbl...
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...b;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
bi******@wordsite.com

Nov 21 '05 #2
Hi Helmut,
x = rngSource.FormattedText
rngDestination.FormattedText = x
Thanks for taking a stab at this. I tried your idea, to no avail. With x
declared as Object, the first line runs but the second triggers the error
that has plagued me from the beginning.

Fellow VB-types have been so bereft of ideas that I may have to drop into a
CSharp group and see if someone there can at least explain how the process
is breaking down, even if there's nothing that can be done about it.

Bill Coan
bi******@wordsite.com
"Helmut Obertanner" <ob********@datalog.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Hi,

have you tried:

x = rngSource.FormattedText
rngDestination.FormattedText = x

Maybe this helps.
Greets, Helmut Obertanner
"Bill Coan" <bi******@wordsite.com> schrieb im Newsbeitrag
news:OL**************@TK2MSFTNGP15.phx.gbl...
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...b;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
bi******@wordsite.com


Nov 21 '05 #3
Hi Bill,
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...b;en-us;292744

Have you seen this KB article:
http://support.microsoft.com/default...b;en-us;313104

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

Nov 21 '05 #4
> Have you seen this KB article:
http://support.microsoft.com/default...b;en-us;313104
Hi Cindy,

Thanks, but this is essentially the same article as the one I referenced in
my question. No new information there. Both articles /recommend/ late
binding, which is the cause of the problem I'm trying to solve.

A number of fellow MVPs have offered some useful suggestions for further
research. I will post back here after I've had an opportunity to complete my
research.

Bill Coan
bi******@wordsite.com
"Cindy M -WordMVP-" <C.*********@hispeed.ch> wrote in message
news:VA.0000a84d.0044e3fc@speedy... Hi Bill,
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...b;en-us;292744

Have you seen this KB article:
http://support.microsoft.com/default...b;en-us;313104

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Robert | last post: by
1 post views Thread by G Fernandes | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.