Re: Accessing a TextBox

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Jim,

Need more details, please...

- Does the document contain more than one section? If so, which section is
the table in?
- Is the table in the primary footer, rather than the first-page or
even-page footer?
- Is it the only table in that footer?
- Which cell should the number be put into? Is it a particular cell in a
known row and column, or do you have to find it by searching for something
(if so, what?)
- Is the variable a number type (Integer, Single, etc.) or a String or a
Variant?
- Does it need to be formatted in any special way (leading zeros, etc.)?
- (least important) What's the name of the variable?

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Jim wrote:
> I am trying to do something similar to what I see in Jay's answer,
> but not quite the same. I am trying to paste a number I have stored
> as a variable into a cell of a table which is embedded in a footer.
> Any ideas on how to do this would be appreciated.
>
> "Jay Freedman" wrote:
>
>> Stefan_B wrote:
>>> Hello,
>>>
>>> I have a textbox which sits in the header of a document, is their
>>> anyway I can access the textbox, so that I may search the Header for
>>> particulars pieces of text?
>>>
>>> Thanks,
>>> Stefan.
>>
>> Hi Stefan,
>>
>> The following code assumes that "the header" means the primary
>> header of section 1 (there could be first-page and/or even-page
>> headers, or you could want a different section), that the header
>> actually contains at least one shape object (a text box is a shape
>> object), and that the first shape is the textbox you want to search.
>> If any one of these assumptions isn't true, the On Error trap will
>> be triggered and the macro will simply exit. In a real macro, you
>> should test each assumption in turn and handle any problems
>> appropriately.
>>
>> It also assumes you're just searching for the first occurrence of
>> the text "find me" -- of course, that can be changed, and the search
>> can be altered to become a replacement. All the interesting stuff is
>> in the Set oRg statement.
>>
>> Sub foo()
>> Dim oRg As Range
>>
>> On Error GoTo Bye
>>
>> Set oRg = ActiveDocument.Sections(1) _
>> .Headers(wdHeaderFooterPrimary).Shapes(1) _
>> .TextFrame.TextRange
>>
>> With oRg.Find
>> .ClearFormatting
>> .Format = False
>> .Forward = True
>> .Wrap = wdFindStop
>> .Text = "find me"
>> If .Execute Then
>> oRg.Select
>> End If
>> End With
>>
>> Bye:
>> End Sub
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org


.



Relevant Pages

  • Re: Background watermark
    ... Another option is to put the text in a textbox ... anchored to the header or footer. ... Use a big bold font, ...
    (microsoft.public.word.pagelayout)
  • Need help using DIVs to replace TABLEs
    ... I have been searching for the past few hours to find ... is to display HTML content in a powerpoint-esque way, with header & ... footer, a menu to the left, and an iframe (where the content is ...
    (comp.infosystems.www.authoring.stylesheets)
  • Re: Headers and Footers in Main Body with Table Breaks
    ... header and footer - unfortunately Word doesn't do this. ... Insert a textbox in the first cell on the first row on the page. ... programming language and SAS creates reports in RTF format. ...
    (microsoft.public.word.pagelayout)
  • RE: Page numbers at the same place with portrait/landscape sections?
    ... You may be able to use the following workaround: Put a textbox in the ... header or footer of the landscape page, insert the page number, change the ... Make sure that your header or footer on the ...
    (microsoft.public.word.docmanagement)
  • Re: Create footer outside of page border
    ... If you select the footer (or header), you can insert a textbox (or just ... about any other object, picture, etc) there and position it wherever ...
    (microsoft.public.word.pagelayout)