|
-
Feb 8th, 2000, 09:12 AM
#1
Thread Starter
Lively Member
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????
-
Feb 8th, 2000, 09:49 AM
#2
Fanatic Member
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!
.
-
Feb 8th, 2000, 09:54 AM
#3
Thread Starter
Lively Member
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???????
-
Feb 8th, 2000, 10:25 AM
#4
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|