We help IT Professionals succeed at work.

Who do I create a formula in a VBA macro that will transfer the result to my Word 2010 document?

cowboywm
cowboywm asked
on
Medium Priority
73 Views
Last Modified: 2020-01-31
I want to create a macro that will add to my Word document at a defined bookmark the result of a formula based on a valued from a dialog box text box “2 * ClothingSections.DaysTextBox.Text”, (i.e. 2 x 18).  Is this possible?  I’ve tried and research a number of things but it’s not working or making sense.  Please see document and picture of form attached.Dialog BoxClothing-List.dotm
Comment
Watch Question

Production Manager
CERTIFIED EXPERT
Commented:
You'll be relaying information to the bookmarks from the userform using statements something like the following. These statements go in the OKButton_Click() sub:

ActiveDocument.Bookmarks("Underwear").Range.Text = NumofDays.value * 1.1    'The bookmark is in the document, the NumofDays field is in the user form. Assumes 1 pair/day plus 1 or 2 extras over an 18 day trip.

If this isn't clear, please post the code or the document you're using.

Author

Commented:
Thanks, John.  This did the trick.

ActiveDocument.Bookmarks("Glucose").Range.Text = ClothingSections.DaysTextBox.Value * 2

Bill