Results 1 to 5 of 5
  1. #1
    New Lounger BaroNessie's Avatar
    Join Date
    Aug 2012
    Location
    USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Beginner: Need help with creating auto-fill based on option button...

    Okay. I apologize in advance, I am extremely new to VBA and fieldcodes and everything but I am very willing to learn. I'm trying to set up a project where I can ask a question with option buttons and based on the answer, it will fill in information below. I've been looking around online for weeks and have an odd collection of codes like :

    Sub FillUsers()
    ActiveDocument.FormFields("Creative").Result = ActiveDocument.Bookmarks("Sparkles").Range.Text
    ActiveDocument.FormFields("Industrial").Result = ActiveDocument.Bookmarks("Wrench").Range.Text
    End Sub

    I want the outcome to be something like this but I am definitely struggling.


    ie:
    What type of project is it?
    a. Creative
    b. Industrial
    c. Etc

    You will need _______, _________, and ______.

    This is probably a bad way to learn but I really would appreciate any help. Again, I'm sorry I'm so new to this and sorry if my questions are stupid.

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    For some introductory material, code, etc, see: http://gregmaxey.mvps.org/word_tip_p...ting_data.html

    If nothing there suits your needs, let us know.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    New Lounger BaroNessie's Avatar
    Join Date
    Aug 2012
    Location
    USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So I looked all through that page and didn't see anything that could give new information based on an optionbutton. All I read was how to repeat and reference something multiple times... Is it possible to do what I mentioned above?

  4. #4
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,191
    Thanks
    48
    Thanked 985 Times in 915 Posts
    This isn't as simple as it sounds. You need to break it down into steps and work on each one in turn.
    1. Define where you are going to put your data. Do you need to put the data into a new row or overwrite the existing?
    2. Decide what data the buttons will enter into the data cells. You may need to keep a list of possible values.
    3. Enter data into the data cells. Do this in code first, then you can work on the buttons.
    4. Add some buttons to tie into the code.
    5. Save?

    cheers, Paul

  5. #5
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi BaroNessie,

    It's not at all clear how well you understand how to go about your project, which is why I gave you the link. You refer to wanting to "a question with option buttons and based on the answer, it will fill in information", but that presupposes a useform, which may be overkill for what you want. For the Project type, for example, you could use a Dropdown Formfield or Dropdown Content Control. If you use a Dropdown Formfield, populating the document may not require any vba at all. That's a bonus where users/organisations have an aversion to running macros.

    Paul: Your reference to 'data cells' suggests you're thinking in terms of Excel, whereas expressions like 'fieldcodes' and 'ActiveDocument.FormFields("Creative").Result = ActiveDocument.Bookmarks("Sparkles").Range.Text' in the OP's posts suggest Word. Nevertheless, the thrust of your post is correct.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Tags for this Thread

Posting Permissions

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