Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 02-10-2019, 03:39 AM
aee74 aee74 is offline Userform selectbox to insert autotext Windows 10 Userform selectbox to insert autotext Office 2013
Novice
Userform selectbox to insert autotext
 
Join Date: Feb 2019
Posts: 5
aee74 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
You have posted a sub with input variables which means this macro can't be run directly, it has to be passed some extra information in order to run). The sub also needs modification in order to use the variables that it expects to be passed in. To run it, you need a separate subroutine which passes in the variables and also to fix the function. Try
Code:
Sub Test_AutoTextToBM()
  AutoTextToBM strbmName:="bm1", oTemplate:=ActiveDocument.AttachedTemplate, strAutotext:="tekstbm1"
End Sub

Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String)
  'If CheckBox1 = True Then
  Dim oRng As Range
  On Error GoTo lbl_Exit    'will avoid errors if bookmark doesn't exist or AT doesn't exist in attached template
  Set oRng = ActiveDocument.Bookmarks(strbmName).Range
  Set oRng = oTemplate.AutoTextEntries(strAutotext).Insert(Where:=oRng, RichText:=True)
  ActiveDocument.Bookmarks.Add Name:=strbmName, Range:=oRng
lbl_Exit:
  Exit Sub
  'End If
End Sub

It works. Great. Thanks
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
insert Autotext via button only from specified category lodi123 Word VBA 0 07-26-2017 02:57 AM
Userform selectbox to insert autotext How do I programmatically insert and append the text from AutoText 0002 to the end of the existing t erik816 Word VBA 1 03-09-2016 12:48 AM
UserForm of Autotext Entries ptmuldoon Word VBA 11 02-13-2016 09:36 AM
Userform selectbox to insert autotext How do i insert autotext using a contol toolbox checkbox NP85 Word VBA 12 02-09-2014 03:06 PM
Userform selectbox to insert autotext Insert identifiers in AutoText snippet. Microsoft word deepgreen Word 13 01-21-2014 05:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:16 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