![]() |
#1
|
|||
|
|||
![]()
Hi,
I am able to find text box. However I am not sure how I can find text frame. This is the code that I have tried Code:
ActiveDocument.Shapes.Item.TextFrame.TextRange.Text |
#2
|
||||
|
||||
![]()
You can find a given frame's text via code like:
MsgBox ActiveDocument.Frames(1).Range.Text
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Hi, macropod
Thanks for your help! May I know how to get specific word from text frame? These are the codes that I have tried Code:
Sub Frame() Dim oTxt As TextRange2 Dim oTxt2 As TextRange2 MsgBox ActiveDocument.Frames(1).Range.Text Set oTxt = ActiveDocument.Frames(1) Set oTxt2 = oTxt.Find("Technology",True) If Not oTxt2 Is Nothing Then MsgBox "Something" End If End Sub |
#4
|
||||
|
||||
![]()
How about:
MsgBox ActiveDocument.Frames(1).Range.Words(1).Text
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Hi, macropod
Thank you for your help, it works! However, may I ask what if you do not want to manually get the specific word? Is it use the .Find ? Thank you |
#6
|
||||
|
||||
![]()
You could use .Find - but only if you know what the word is. But, if you know what the word is, why are you trying to .Find it? Alternatively, you could use Instr. For example:
If Instr(ActiveDocument.Frames(1).Range.Text, "Technology")> 0 Then With such a test, you can establish whether the word 'Technology' is present - and even where it starts in the frame.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
||||
|
||||
![]()
Perhaps you need to explain fully what it is you want to do. To find a particular word by searching through all the text frames in a document the code would look like
Code:
Sub GetAWord() Dim aFrame As Frame, aRng As Range For Each aFrame In ActiveDocument.Frames Set aRng = aFrame.Range With aRng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "Technology" If .Execute Then aRng.Select MsgBox "Found one of 'em" End If End With Next aFrame End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Jovan Yong | Word VBA | 5 | 04-09-2018 02:59 AM |
![]() |
hauswalter | Word | 11 | 10-20-2015 02:38 AM |
![]() |
gandalf458 | Word | 4 | 12-10-2014 03:04 AM |
![]() |
blockie | Word | 2 | 08-21-2014 07:51 PM |
![]() |
peacespotting | Word | 1 | 08-08-2013 10:39 PM |