|
From: Stuart Troy on 1 Jul 2008 19:48 I have created a template containing AutoText entries. How can I create a new blank document based upon Normal.DOT and insert the AutoText entries from my custom template - without referencing a filename path to my custom template, as its location is likely to change.
From: Jonathan West on 1 Jul 2008 20:45 "Stuart Troy" <StuartTroy(a)discussions.microsoft.com> wrote in message news:93F6B8EE-70FB-40C6-8475-DC9EC0593E36(a)microsoft.com... >I have created a template containing AutoText entries. > > How can I create a new blank document based upon Normal.DOT and insert the > AutoText entries from my custom template - without referencing a filename > path to my custom template, as its location is likely to change. If you put your custom template in the Startup folder, it will be loaded as an add-in and its autotext entries will be available to the user. You can reference a member of the add-ins collection by means of its filename, without needing the full pathname. -- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup
From: Stuart Troy on 2 Jul 2008 07:17 Thanks Jonathon, I moved the custom template to Word's startup folder; C:\Documents and Settings\UsernameApplication Data\Microsoft\Word\STARTUP But when I run this code, it produces an error; VBA Code; Documents.Add DocumentType:=wdNewBlankDocument ActiveDocument.AttachedTemplate.AutoTextEntries("AutoText_Name"). Insert Where:=Selection.Range, RichText:=False Resulting Error; "The requested member of the collection does not exist"
From: Jonathan West on 2 Jul 2008 08:31 "Stuart Troy" <StuartTroy(a)discussions.microsoft.com> wrote in message news:084E1460-DAED-402E-83FB-B91F561879A4(a)microsoft.com... > Thanks Jonathon, > > I moved the custom template to Word's startup folder; > C:\Documents and Settings\UsernameApplication Data\Microsoft\Word\STARTUP > > But when I run this code, it produces an error; > > VBA Code; > Documents.Add DocumentType:=wdNewBlankDocument > ActiveDocument.AttachedTemplate.AutoTextEntries("AutoText_Name"). Insert > Where:=Selection.Range, RichText:=False > > Resulting Error; > "The requested member of the collection does not exist" > That is because you are specifying that thst autotext entry must come from the ActiveDocument.AttachedTemplate. It isn't there, it is in the add-in. Suppose your addin id called MyAddin.dot. You need to identidy the aadd-in and then use that as the source of the Autotext entry. Something like this Dim oTemplate as Template For each oTemplate in Templates If oTemplate.Name = "MyAddin.dot" Then Exit For Next oTemplate oTemplate.AutoTextEntries("AutoText_Name"). Insert Where:=Selection.Range, RichText:=False -- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup
From: Jean-Guy Marcil on 3 Jul 2008 07:53 "Stuart Troy" wrote: > Thanks Jonathon, > > I moved the custom template to Word's startup folder; > C:\Documents and Settings\UsernameApplication Data\Microsoft\Word\STARTUP > > But when I run this code, it produces an error; > > VBA Code; > Documents.Add DocumentType:=wdNewBlankDocument > ActiveDocument.AttachedTemplate.AutoTextEntries("AutoText_Name"). Insert > Where:=Selection.Range, RichText:=False > > Resulting Error; > "The requested member of the collection does not exist" As an alternative to Jonathan's suggestion, you can also do it without even referencing any template. As long as it is indeed in the Startup folder and that the AutoText names from that template are unique, you can use: Dim rngAutoText As Range Const strAutoTextName As String = "AutoText_Entry_Name" Set rngAutoText = Selection.Range With rngAutoText 'In case selection is not an insertion point... .Collapse wdCollapseStart .InsertAfter strAutoTextName .InsertAutoText End With If you cannot guarantee unique names, then it is better to use Jonathan's code. If different templates have Autotext entries with the same name, you will pull the right one.
|
Pages: 1 Prev: Does anyone know why EZPhoto keeps showing up in Word? Next: MIME Types |