Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

Insert at caret position

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joshua Ellul - 07 Jun 2007 19:32 GMT
Hi,

I'm trying to insert an image where the caret is position.  I am managing to
insert an image.  The problem is to find the position where the caret is.
Does anyone know how I can get the caret position?

Thanks,

Josh
Graham Mayor - 08 Jun 2007 09:12 GMT
How about

With Selection.Find
   Do While .Execute(findText:="^", _
   Wrap:=wdFindStop, Forward:=True, _
   MatchWildcards:=False) = True

   MsgBox "The carat is here!"

   Loop
End With

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Hi,
>
[quoted text clipped - 5 lines]
>
> Josh
Joshua Ellul - 08 Jun 2007 16:01 GMT
Oppss... I used the wrong term.  I meant the keyboard cursor position, i.e.
where the next character will be displayed when the user types in.

Thanks,

Josh

> How about
>
[quoted text clipped - 17 lines]
>>
>> Josh
Russ - 09 Jun 2007 09:33 GMT
>>> I'm trying to insert an image where the caret is position.  I am
>>> managing to insert an image.  The problem is to find the position
>>> where the caret is. Does anyone know how I can get the caret position?

You can get close to what you need by recording a macro while inserting your
image and then examining the code. Recorded macros normally use the
'selection object' so that they work on what is currently selected in the
document.
The code snippet below checks whether the selection is just an 'insertion
point' and nothing else is selected before adding a picture to the document
at that insertion point. The space, underscore marks at the end of the two
lines are continuation markers; meaning that everything in the middle is
actually one continuous line of code.

If Selection.Type = wdSelectionIP then

   Selection.InlineShapes.AddPicture fileName:= _
       "C:\Your\Path\To\Picture.png", LinkToFile:=False _
       , SaveWithDocument:=True

End If

> Oppss... I used the wrong term.  I meant the keyboard cursor position, i.e.
> where the next character will be displayed when the user types in.
[quoted text clipped - 24 lines]
>>>
>>> Josh

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

Russ - 09 Jun 2007 09:43 GMT
If you needed to know a more geometric, dimensional location of the
insertion point within the page, then I suggest looking at the 'Information
Property' in VBA Help.

>>>> I'm trying to insert an image where the caret is position.  I am
>>>> managing to insert an image.  The problem is to find the position
[quoted text clipped - 46 lines]
>>>>
>>>> Josh

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.