Results 1 to 4 of 4

Thread: need help with this one???

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    81

    Post

    i would like to add a button to microsoft word with my own coding behind it
    so when the button is pressed my code executes is this possible????

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Post

    Hi Johnny.

    Sure it's possible! Here are the steps:

    1) Create a new Word document.

    2) Select View, Toolbars, Control Toolbox.

    3) Click on a Command button.

    4) Now double-click on the Command button in your document, which will take you to the Code Editor.

    5) Paste this code there:
    Code:
    Option Explicit
    
    Private Sub CommandButton1_Click()
        MsgBox "Hi Johnny", vbInformation, "VBA Word"
    End Sub
    6) Select Word from the Taskbar.

    7) Click on Exit Design Mode on the Control Toolbox.

    Finally, click on the Command button.

    Be advised that Word uses VBA which is similar to, but not identical with, VB. You should get a good book on VBA to learn more about coding in Word.

    All the best.

    ------------------
    OneSource
    The truth may be out there, but it's in here too!
    .

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Posts
    81

    Post

    im sorry i don't know if i asked the question right , what i mean is i need to do that from a vb application that im writing it needs to open word then create a new button with my coding behind it as about 1000
    users will be using that button to send generated letters to a fax server
    any ideas???????

  4. #4
    New Member
    Join Date
    Feb 2000
    Location
    Belgrade, YU
    Posts
    4

    Post

    It is possible (you have to create Macro).
    In MS Word go to Menu option: View/Toolbars/Visual Basic to display VB toolbar. From that panel choose button with tooltip 'Control Toolbox' and you'll get another toolbox with VB controls, on which you'll see the Command Button control you want to put on your page. When you click on the Command Button control from the control toolbox, you'll get Command Buton on your page. You can move it where you want while you are in Design mode. Like in VB you'll see Properties and View code buttons at the top of control toolbox. You can modify your button by changing its properties. Pressing on View code button, you'll open another window (classic VB code window), where you can put your code. When you finish with coding and properties, you will have to exit design mode to try your Macro. You can start it from Visual Basic toolbox, by pressing Run button (like in VB), but you will be asked to create macro first, and then the Run button will be enabled.
    You can also record your macro, by pressing Record button on VB toolbox.

    ------------------
    Kameni

Posting Permissions

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



Click Here to Expand Forum to Full Width