Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Text property in ..Interop::Word::Range don't show

18 views
Skip to first unread message

Sérgio Carvalho

unread,
Sep 23, 2009, 9:08:01 AM9/23/09
to
Hello,

I'm for the first time using Microsoft::Office::Interop::Word but I have one
problem, in my Range object the property Text don't exist.

My code:

Bons dias,

Estou pela primeira vez a utilizar o Automation do Word no VC++.Net 2005 e
estou com um problema, quero escrever no sitio de um determinado marcador,
mas~o objecto Range não tem a propriedade Text e em todos os exemplos que
vejo é com esta propriedade que escrevem, aqui fica o código:

private: System::Void ReplaceBookmarkText (
Microsoft::Office::Interop::Word::_Document^ doc,
System::String^ bookmarkName,
System::String^ text)
{
if ( doc->Bookmarks->Exists(bookmarkName) )

{

System::Object^ name = bookmarkName;

Microsoft::Office::Interop::Word::Range^ oRange =
doc->Bookmarks[bookmarkName]->Range;

oRange->Text = text; // LINE WITH ERROR

System::Object^ newRange = oRange;

doc->Bookmarks->Add(bookmarkName, newRange);

}

}

Details of Errors

Error 1 error C2872: 'Text' : ambiguous symbol
Error 2 error C2882: 'Text' : illegal use of namespace identifier in
expression

Sérgio Carvalho

unread,
Sep 23, 2009, 9:30:02 AM9/23/09
to
New details of the error

error C2872: 'Text' : ambiguous symbol

1> could be 'System::Drawing::Text'
1> or 'System::Text'

Sérgio Carvalho

unread,
Sep 23, 2009, 12:47:01 PM9/23/09
to
The alternative


private: System::Void ReplaceBookmarkText (

Microsoft::Office::Interop::Word::_Document^ doc,
System::String^ bookmarkName,

System::String^ texto)
{

if ( doc->GoTo(Bookmarks->Exists(bookmarkName) )
{

System::Object^ name = bookmarkName;

Microsoft::Office::Interop::Word::Range ^oRange =

doc->Bookmarks[name]->Range;

oRange->Select();

Microsoft::Office::Interop::Word::Selection^ currentSelection =
wordApp->Selection;

// Test to see if selection is an insertion point.
if (currentSelection->Type ==
Microsoft::Office::Interop::Word::WdSelectionType::wdSelectionIP)
{
currentSelection->TypeText("Inserting at insertion point. ");
//currentSelection->TypeParagraph();

0 new messages