vba - How do I insert text at my cursor location in Word? -


i'm trying have excel macro insert text @ cursor location in already-opened word document.

this have written. i'm aware activedocument.range has start , end arguments, cannot seem able assign them "current selection" value. help? thanks?

sub inserttext()  dim rngtemp word.range  set rngtemp = activedocument.range  rngtemp      .insertafter "this sample text"     .font.name = "tahoma"     .font.size = 11     .insertparagraphafter end  end sub 

the current selection selection.

if, indicate, need use in excel macro that's automating word, need use word.application object you've declared , instantiated qualify it. this:

dim wdapp word.application set wdapp = getobject(, "word.application") wdapp.selection.text = "text @ current selection" 'get range current selection dim rng word.range set rng = wdapp.selection.range rng.text = "this text replace text in current selection" rng.collapse wdcollapseend rng.text = " , text come after current selection" 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -