Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2016, 08:59 PM
erik816 erik816 is offline How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t Windows 10 How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t Office 2007
Novice
How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t
 
Join Date: Mar 2016
Posts: 2
erik816 is on a distinguished road
Default How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t

Goal


I am trying to use VBA to programmatically insert and append the text from AutoText 0002 to the end of the existing text in the DraftingField below, if any.

Catalog of AutoText statements:
0001
This text was inserted using 0001 and is paragraph 1 with cool Choose an item.. blah blah.

0002
This text was inserted using 0002 and should be paragraph 2 and appear directly below paragraph 1 in the drafting field, not write over the existing data in the field. Click here to enter a date.. blah blah and more Click here to enter text.


Validation when successful:

If the buttons work correctly as desired, after clicking “Insert 0001” the DraftingField should read:
“This text was inserted using 0001 and is paragraph 1 with cool Choose an item.. blah blah.”

Then, if I click “Insert 0002”, the DraftingField should add the text from AutoText 0002 to the end of the existing text in the field and the field should read:

“This text was inserted using 0001 and is paragraph 1 with cool Choose an item.. blah blah. This text was inserted using 0002 and should be paragraph 2 and appear directly below paragraph 1 in the drafting field, not write over the existing data in the field. Click here to enter a date.. blah blah and more Click here to enter text.


· My current code is:
Private Sub Insert0001_Click()

Selection.GoTo What:=wdGoToBookmark, Name:="DraftingField"

Application.Templates("C:\Users\erikm\Desktop\test .dotm").BuildingBlockEntries("0001").Insert Where:=Selection.Range, RichText:=True

End Sub

Private Sub Insert0002_Click()
Selection.GoTo What:=wdGoToBookmark, Name:="DraftingField"
Application.Templates("C:\Users\erikm\Desktop\test .dotm").BuildingBlockEntries("0002").Insert Where:=Selection.Range, RichText:=True
End Sub

I have the Word file created with AutoText 0001 and 0002 and the AutoText and their drop down menus, date picker, and enter text controls work perfectly. The buttons work, but when I click button 0001 and then click button 0002, the text from AutoText 0002 overwrites the existing text (text inserted from AutoText 0001) in my DraftingField. Instead, I want button 0002 to append its text to the end of any text already in the DraftingField.

I have attached the file.
Thanks!
Attached Files
File Type: dotm test.dotm (36.3 KB, 8 views)
Reply With Quote
  #2  
Old 03-09-2016, 12:48 AM
macropod's Avatar
macropod macropod is offline How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t Windows 7 64bit How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: https://social.msdn.microsoft.com/Fo...?forum=worddev
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t Insert Existing Comments at the End of Comment Selection Text mercadogs Word VBA 3 12-31-2015 03:49 AM
How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t Append to Existing file charlesdh Word VBA 12 07-30-2015 08:21 PM
How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t How do i insert autotext using a contol toolbox checkbox NP85 Word VBA 12 02-09-2014 03:06 PM
How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t Insert identifiers in AutoText snippet. Microsoft word deepgreen Word 13 01-21-2014 05:16 PM
Append text to a cell with color gvdm Excel 1 04-17-2012 10:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:40 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft