Results 1 to 5 of 5

Thread: Help in VB writing Macros in Ms Word

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    3

    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:
    1. Private Sub Document_Open()
    2. ListBox1_Click
    3. End Sub
    4.  
    5. Private Sub ListBox1_Click()
    6.  Me.ListBox1.AddItem "A1"
    7.  Me.ListBox1.AddItem "B1"
    8.  Me.ListBox1.AddItem "C1"
    9.  Me.ListBox1.AddItem "D1"
    10.  Me.ListBox1.AddItem "E1"
    11.  Me.ListBox1.AddItem "F1"
    12.  Me.ListBox1.AddItem "G1"
    13.  Me.ListBox1.AddItem "H1"
    14.  Me.ListBox1.AddItem "I1"
    15.  Me.ListBox1.AddItem "K1"
    16.  Me.ListBox1.AddItem "L1"
    17.  Me.ListBox1.AddItem "M1"
    18. 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,

  2. #2
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    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?
    CS

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    3

    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 Attached Files

  4. #4
    New Member
    Join Date
    Feb 2006
    Posts
    7

    Talking 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

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    3

    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
  •  



Click Here to Expand Forum to Full Width