![]() |
#1
|
|||
|
|||
![]()
So I am trying to build a vba code to only generate a string of data concactenated from various textboxes if the initial box has been edited.
For context I'm trying to list schedules for an unknown # of people. I have a User form i'm piggybacking off of for fields that include: Person name, days attending, and hours. I have these boxes for up to 10 people currently and my end goal is to generate a line in my word document at a specific bookmark only if Person Name field textbox on the userform has been changed. My fields on the userform read as: PNBox DABox HABox 1PNBox 1DABox 1HABox ... all the way to 10 assuming i fill in the info for the first two people the following two lines would generate John Doe, Mon- Fri, 8:00am - 5:00pm Jane Doe, Mon- Thu, 8:00am - 5:00pm however, here's where i'm having the issue... I want to use the Bookmarks.Add method and only want it to generate the bookmarks for days and hours IF the name field has been changed. I hope i've explained that well enough. Cause otherwise I have a section in my document that is just , , , , where I have the bookmarks built in around the commas I'm a total noob at VBA but i've managed to complete all other things i'm trying to do, it's this bit of code I can't seem to pull together. This is all i've got, please don't laugh :P Code:
Dim Temp As Range If ActiveDocument.Bookmarks.Exists("bmPN") Then If Me.PNBox.Value <> “Persons Name” Then ActiveDocument.Bookmarks("bmPN").Range.InsertAfter _ ", " ActiveDocument.Bookmarks.Add Name:="bmDA ActiveDocument.Bookmarks("bmDA").Range.InsertAfter _ ", " ActiveDocument.Bookmarks.Add Name:="bmHA Set Temp = ActiveDocument.Bookmarks("bmPN").Range Temp.Text = Me.PNBox.Value End If End If ...Help |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
wardw | Word | 7 | 05-07-2018 09:13 AM |
![]() |
Amitti | Word VBA | 2 | 04-10-2017 07:35 PM |
How to find all string within string. | PRA007 | Word VBA | 18 | 02-12-2016 08:11 PM |
![]() |
omahadivision | Excel Programming | 12 | 11-23-2013 12:10 PM |
![]() |
scarymovie | Word VBA | 5 | 05-16-2012 07:05 PM |