Share via

VBA Code for word document template by using Userform

Anonymous
2019-03-27T13:09:45+00:00

Hi 

If i have word document template. I want to create userform and user can input text and select option to choose. what to delete and what to keep from template. (might be paragraph as well)

I know, the option by creating bookmarks and write VBA code.

I am looking alternate option as i dont want to create bookmarks. 

Is there any option by creating textfield or formfield. and code in VBA?  somethign like in bracket <<textdemo>>

Please let me know 

Thank you

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2019-03-27T23:27:36+00:00

    Use DOCVARIABLE fields

    You could have the text that you may want to delete in a document variable so that it appeared in such a field, and if you want it to be deleted, use code to set the value of the variable to a single space.  

    See the following pages of Greg Maxey's website :

    http://gregmaxey.mvps.org/Create\_and\_employ\_a\_UserForm.htm

    http://gregmaxey.mvps.org/Populate\_UserForm\_ListBox.htm

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2019-03-28T22:42:58+00:00

    Hi Robbins

    Thank you so much for these website.  It really looks what i want. I haven't try it yet.

    However, i have 2 questions: 

    1.  This guide does not have the information about how to delete the paragraph from template. 

    example:  User will select something which needs to reflect on document as such related paragraph will delete from user end document.

    1. what about merge field instead of docvariable field. can we use and how?

    I will appreciate if you provide me something more information about it

    Thank you

    Was this answer helpful?

    0 comments No comments