My first macro in word

Pcguru

New member
Local time
Yesterday, 16:16
Joined
Sep 28, 2008
Messages
7
1 day old to VB and I think that I want something simple. In word I would like 5 checkboxes and I would like VB to take the sum of the checked checkboxes and put them into a paragraph.

Example:
For some reason the example bmp is at the bottom of the post.

The out put would go somewhere on the open word document and in this example it would say.

Hello jack how was your trip?

This script might go something like this

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 9/28/2008 by WinXp
'
If Checkbox 1 = checked
string tipe = type + Hello
End If
If Checkbox 2 = checked
string tipe = type + bob
End If
If Checkbox 3 = checked
string tipe = type + jack
End If
If Checkbox 4 = checked
string tipe = type + How are you
End If
If Checkbox 5 = checked
string tipe = type + how was your trip?
End If

Selection.TypeText Text:=tipe
End Sub

I would appreciate all the help I can get!
 

Attachments

I would like to thank all of you for the worm welcome and all of your help with what to you is a simple macro in word. When I joined 2 days ago I was concerned that no one would help a newbie. I am glad to see that I was wrong.

Thank you.
 
I seem to be sensing a little frustration and a lot of sarcasm (or is it the other way around?).

Most of the people posting here are experts in VB for MS Access and MS Excel (they seem to go hand in hand a lot). I am sure that there are experts in a few other MS Office products as well, but I have not seen many posts from them. I know nothing about Macros or VB in MS Word at all. Sorry for the lack of response, and good luck in finding out what you want.
 
Since this forum is an Access forum with Excel and Word only getting a very small minority of postings and the fact you did not post this in the Word forum but in the Access General Forum I am assuming Access is the main thing for you.

If that is the case then the question you are asking is probably best answered if it is done in Access code. You can put code behind an Access button or label that will open a specific Word. doc and insert the value of an Access control into a Word book mark.

You could have a textbox on an Access form that gets it value when you click your one of your check boxes. Thus if you click checkbox one then "Hello" will go into the textbox on the form. Access would then insert "Hello" into the Word.doc.
 
Guru,

I do know how to do this, but I do not have time to write the code for you. I can say this though: If you want to write code applicable to MS WORD, in Access, the best thing to do is test it in WORD itself where you get the added benefit of the intellisense dropdown lists to see if it is really going to work. Use your bookmarks, and test what you can in WORD. Then when you get it working, transfer the objects over to Access and write the appropriate syntax from that program. It will not be that much different. The references will just be longer.

For example, the following in WORD:
Code:
[COLOR="Red"]activedocument.activate[/COLOR]
would have to be written like the following in Access:
Code:
dim wrd as word.application
dim doc as wrd.documents.open("path of word doc")
  wrd.visible = true

[COLOR="Red"]doc.activate[/COLOR]
(or something similar to that). I hope you see what I'm getting at...
 
Since this forum is an Access forum with Excel and Word only getting a very small minority of postings and the fact you did not post this in the Word forum but in the Access General Forum I am assuming Access is the main thing for you.

If that is the case then the question you are asking is probably best answered if it is done in Access code. You can put code behind an Access button or label that will open a specific Word. doc and insert the value of an Access control into a Word book mark.

You could have a textbox on an Access form that gets it value when you click your one of your check boxes. Thus if you click checkbox one then "Hello" will go into the textbox on the form. Access would then insert "Hello" into the Word.doc.

Do you have a Word forum or can you direct me to a Word forum as you can see I am new and I do not understand anything except that this was a General place to post.

As far as the post I made the help that I got was a few people sending me Emails. Even though they where not what I needed I have learned a lot in the last 2 days.

 
Do you have a Word forum or can you direct me to a Word forum as you can see I am new and I do not understand anything except that this was a General place to post.



Just scroll down the index page of this site and you will see a Word forum. However, it is not very active.

I agree with what MSAccessRookie said although I know ajetrumpet covers Access, Word and Excel extensively but relying on one or two posters is not real good. As such I would suggest that you do some searcing on Google and include Word and Macro in your search. Such searches usually turn up a lot of forums and you will probably get one where Word is the main theme of the forum.

Hope that helps.
 
Do you have a Word forum or can you direct me to a Word forum
Word Forums are OK, but the Microsoft Help menus insides the programs are the best. That is what I use most often, mostly because I forget how to do things after I've done them once or twice!

Many people say the help menu is no good, but believe me it is. If you know how to use the information given in those files, they can do you a world of good. For the stuff that you are getting into here, the research should be on objects themselves. You can write a document in word, but when you start playing around with stuff like this, you should start looking at the program as just a bunch of objects (like documents, checkboxes, bookmarks, ranges of text, etc...). That's what VBA is all about (the objects of the program).
 
Word Forums are OK, but the Microsoft Help menus insides the programs are the best. That is what I use most often, mostly because I forget how to do things after I've done them once or twice!

Many people say the help menu is no good, but believe me it is. If you know how to use the information given in those files, they can do you a world of good. For the stuff that you are getting into here, the research should be on objects themselves. You can write a document in word, but when you start playing around with stuff like this, you should start looking at the program as just a bunch of objects (like documents, checkboxes, bookmarks, ranges of text, etc...). That's what VBA is all about (the objects of the program).

Than you all and I will try it all!
 

Users who are viewing this thread

Back
Top Bottom