Microsoft Office Forums How to find text frame in Word Document ?

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2019, 09:15 AM
BeginnerLearner BeginnerLearner is offline How to find text frame in Word Document ? Windows 10 How to find text frame in Word Document ? Office 2013
Novice
How to find text frame in Word Document ?
 
Join Date: Feb 2019
Posts: 22
BeginnerLearner is on a distinguished road
Default How to find text frame in Word Document ?

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
Thank you
Reply With Quote
  #2  
Old 02-10-2019, 01:06 PM
macropod's Avatar
macropod macropod is offline How to find text frame in Word Document ? Windows 7 64bit How to find text frame in Word Document ? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

You can find a given frame's text via code like:
MsgBox ActiveDocument.Frames(1).Range.Text
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 02-10-2019, 06:03 PM
BeginnerLearner BeginnerLearner is offline How to find text frame in Word Document ? Windows 10 How to find text frame in Word Document ? Office 2013
Novice
How to find text frame in Word Document ?
 
Join Date: Feb 2019
Posts: 22
BeginnerLearner is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 02-10-2019, 06:22 PM
macropod's Avatar
macropod macropod is offline How to find text frame in Word Document ? Windows 7 64bit How to find text frame in Word Document ? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

How about:
MsgBox ActiveDocument.Frames(1).Range.Words(1).Text
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 02-11-2019, 03:27 AM
BeginnerLearner BeginnerLearner is offline How to find text frame in Word Document ? Windows 10 How to find text frame in Word Document ? Office 2013
Novice
How to find text frame in Word Document ?
 
Join Date: Feb 2019
Posts: 22
BeginnerLearner is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 02-11-2019, 01:53 PM
macropod's Avatar
macropod macropod is offline How to find text frame in Word Document ? Windows 7 64bit How to find text frame in Word Document ? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

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
[MS MVP - Word]
Reply With Quote
  #7  
Old 02-11-2019, 02:17 PM
Guessed's Avatar
Guessed Guessed is offline How to find text frame in Word Document ? Windows 10 How to find text frame in Word Document ? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 1,182
Guessed has a spectacular aura aboutGuessed has a spectacular aura aboutGuessed has a spectacular aura about
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find text frame in Word Document ? Find and highlight text in MS Word document containing word Jovan Yong Word VBA 5 04-09-2018 02:59 AM
How to find text frame in Word Document ? how to get a startpage like at word 2010 (text frame at margins) hauswalter Word 11 10-20-2015 02:38 AM
How to find text frame in Word Document ? Trouble fomatting a frame - top of letter cut off in frame - line spacing gandalf458 Word 4 12-10-2014 03:04 AM
How to find text frame in Word Document ? Cannot get rid of a border in a frame or text box blockie Word 2 08-21-2014 07:51 PM
How to find text frame in Word Document ? Converting plain text to text box/frame peacespotting Word 1 08-08-2013 10:39 PM


All times are GMT -7. The time now is 05:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft