Consulting

Results 1 to 6 of 6

Thread: Solved: Word Constants

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Solved: Word Constants

    A simple little task, but I'm not getting it!
    Move to the start of an opened Word document
    [VBA]
    Set MyRange = Wd.ActiveDocument
    With MyRange
    .MoveStart Unit:=wdStory, Count:=-1
    End With

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    That snippet is trying to move the active document to the start of a, (unspecified,) document.

    Perhaps ypu want
    [vba]
    'This example applies bold formatting to the first 10
    'characters in the active document.
    Sub DocumentRange() ActiveDocument.Range(Start:=0, End:=10).Bold = TrueEnd Sub[/vba]

  3. #3
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    HTH. Dave

    http://peltiertech.com/Excel/EarlyLateBinding.html
    "The easiest way to determine the values of these constants is, before removing the reference to the other application's object model, finding it in the Object Browser, or in the Immediate Window, typing a question mark followed by the constant name, then pressing Enter"


  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks both
    This does what I need
    [VBA]
    Wd.Selection.HomeKey Unit:=6
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Also

    [vba]Wd.Selection.Collapse 0[/vba]

    David


  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks
    I'll try that tomorrow.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •