Feb 16th, 2006, 03:16 PM
#1
Thread Starter
New Member
Help in VB writing Macros in Ms Word
Hi All,
I am trying to incorporate a list box in MS word.
for eg the list box contains with check box:
A1
B1
C1
D1
E1....
I will be selecting more than one item say A1,C1 and E1.
To accomplish this I have written a macro in VBA, Here is the code.
VB Code:
Private Sub Document_Open()
ListBox1_Click
End Sub
Private Sub ListBox1_Click()
Me.ListBox1.AddItem "A1"
Me.ListBox1.AddItem "B1"
Me.ListBox1.AddItem "C1"
Me.ListBox1.AddItem "D1"
Me.ListBox1.AddItem "E1"
Me.ListBox1.AddItem "F1"
Me.ListBox1.AddItem "G1"
Me.ListBox1.AddItem "H1"
Me.ListBox1.AddItem "I1"
Me.ListBox1.AddItem "K1"
Me.ListBox1.AddItem "L1"
Me.ListBox1.AddItem "M1"
End Sub
I saved the word document as XXX.doc and closed.Then when I try again opening XXX.doc, the previous changes are not retained.
How can I accomplish to retain the pervious changes whenever I try to open the document.
Any help will appreciated.
Thanks,
Feb 17th, 2006, 01:14 PM
#2
Re: Help in VB writing Macros in Ms Word
Where did you saved your macros?
Is it in Normal.dot module?
or in ThisDocument ?
Please check or can you please upload a sample file so that we can look at it?
Feb 20th, 2006, 01:13 PM
#3
Thread Starter
New Member
Re: Help in VB writing Macros in Ms Word
Thanks for your response.
Here is the sample doc.I selected and saved the check boxes.Then I try to open it.The changes are not retaining and it initialize the document.
I want to retain the changes.Please suggest me.
Attached Files
Feb 21st, 2006, 03:34 AM
#4
New Member
Re: Help in VB writing Macros in Ms Word
Dude,
Opened your doc, but it looks like the listboxes haven't been placed in the document yet. If you want to add them onto the actual document you'll need to use the Control Toolbox and draw them on, or use code when opening the document to draw and place them.
Hope this helps!
Z
Feb 21st, 2006, 01:13 PM
#5
Thread Starter
New Member
Re: Help in VB writing Macros in Ms Word
Well, I saved the upload document and opened from the Desktop. I can see the listbox.
I did not understand your question as I'm new in writing macros nor I'm a VB programmer.
Let me know if I'm missing someting.
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