Consulting

Results 1 to 3 of 3

Thread: Assign Marco to Text Box

  1. #1
    VBAX Regular
    Joined
    Aug 2019
    Location
    Oxfordshire, UK
    Posts
    9

    Assign Marco to Text Box

    Hi,
    Can anyone help with something that looks like it should be really simple but I canít see how to do it. I have a simple Marco that sorts a table by date. It runs fine. I have put a text box in my document Ďsort by dateí but canít work out how to link the existing Marco to the text box ? Iíve tried right click properties and assign code but itís not very clear how to do this.
    Thanks, if someone could tell me the easy way.
    Rosanna

  2. #2
    A text box? Surely what you want is a button, otherwise what is the relevance of the text box? You can call your macro from the button code. e.g.
    Private Sub CommandButton1_Click()    ActiveDocument.Tables(1).Sort _
                ExcludeHeader:=False, _
                FieldNumber:="Column 1", _
                SortFieldType:=wdSortFieldDate, _
                SortOrder:=wdSortOrderAscending
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Regular
    Joined
    Aug 2019
    Location
    Oxfordshire, UK
    Posts
    9
    OK thanks very much for this, I thought there might be an easier way.
    thanks

Posting Permissions

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