Insert text in word at current cursor's location

S

sreedhardasi

I am writing a Shared COM Add-in for Word and Excel. I am trying to
insert the text in the current cursor's location within the word
document. I got the following code for Excel where it inserts text in
the current active cell.

Dim range As Microsoft.Office.Interop.Excel.Range =
appExcelObj.ActiveCell
range.Value = deValue

How do we do this in Word? Any help is appreciated.

Thanks
 
S

stebain

I am writing a Shared COM Add-in for Word and Excel. I am trying to
insert the text in the current cursor's location within the word
document. I got the following code for Excel where it inserts text in
the current active cell.

Dim range As Microsoft.Office.Interop.Excel.Range =
appExcelObj.ActiveCell
range.Value = deValue

How do we do this in Word? Any help is appreciated.

Thanks

Try Application.Selection.TypeText deValue, where "Application" is changed
to whatever the connection object is named.

Just a quick guess.
 
S

sreedhardasi

Thanks for the reply. The solution worked. Do you know how can we can
achieve this in PowerPoint?
 
S

Steve Rindsberg

Thanks for the reply. The solution worked. Do you know how can we can
achieve this in PowerPoint?


Try:

' First ensure that there's some text selected
' (ppSelectionText is Long = 3)
If ActiveWindow.Selection.Type = ppSelectionText Then
ActiveWindow.Selection.TextRange.InsertAfter ("LOOK! New Text")
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top