Microsoft Excel Webinar

Results 1 to 2 of 2

Thread: Set focus on document from Userform

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

    Set focus on document from Userform

    With reference to my MergeField Select KB entry, I would like it to "Set Focus" to the document after a mergefield is added. The code to add the field is :
    MD

    VB:
     
    Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) 
         'Add listbox item to document
        ActiveDocument.Fields.Add Range:=Selection.Range, Type:=wdFieldMergeField _ 
        , Text:=ListBox1 
    End Sub 
    
    
    Formatting tags added by mark007
    MVP (Excel 2008-2010)

    "Provide sample data and layout if you want a quicker solution." - MD


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,658
    Location
    Blog Entries
    5
    Can you just unload/hide the User Form or are you trying to do something else?

Posting Permissions

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