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
error C2872: 'Text' : ambiguous symbol
1> could be 'System::Drawing::Text'
1> or 'System::Text'
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();