Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2009, 01:31 PM
kelzud kelzud is offline Maintaining AUtotext Entries from an external table. Windows XP Maintaining AUtotext Entries from an external table. Office 2003
Novice
Maintaining AUtotext Entries from an external table.
 
Join Date: Jul 2009
Posts: 1
kelzud is on a distinguished road
Default Maintaining AUtotext Entries from an external table.

Hi, I use office to manage a huge list of autotext entries, and I employ several templates to keep everything oranized. I move all of my commonly used autotexts from Normal.dot to Base.dot, and all the other autotexts I put in specialized templates (investigations, physexam, oncologymeds). Anyways, I have macros to turn add or remove these templates from the current document I am in. This is great.
The latest thing I have been trying to do is manage my autotext entries from an external file (set up for word, prefer excel). I have these two lists of VB code. Oh, I have no idea what any of this means, I just fiddle around and try to make it work!
I got these two pieces of code from: http://www.gmayor.com/AutotextList.htm
The first code looks at the external document (which I wish could be an excel file if anyone nows how to change it) and removes all entries from the normal.dot autotext list that are in that file. Its great!!! I can change where the file is and the name of it and everything. I can even change the template to delete in (in this case, normal.dot, which is listed in the code as NormalTemplate).
This is the delete code:
Sub AutoTextFromTableDelete()
Dim aTextDoc As Document
Dim cTable As Table
Dim rName As Range, rText As Range
Dim i As Long
Dim sFname As String

sFname = "D:\My Documents\Test\AutotextTable.doc"
Set aTextDoc = Documents.Open(sFname)


Set cTable = aTextDoc.Tables(1)

On Error Resume Next
For i = 1 To cTable.Rows.Count
Set rName = cTable.Cell(i, 1).Range
rName.End = rName.End - 1
NormalTemplate.AutoTextEntries(rName).Delete
Next i
aTextDoc.Close wdDoNotSaveChanges
End Sub

The next part of the code is set to populate the Normal.dot template (NormalTemplate) with the autotext entries in the external file. Here is where the problem comes in!!!! This works fine if I leave the template listed as NormalTemplate, but if I try to change it to the Investigations.dot by changing NormalTemplate to InvestigationsTemplate all hell breaks loose! I can still delete the entries in the Investigations.dot but when I click to upload the ones from the external file it will not do it. Here is the error followed by the code.
ERROR:
RUN-TIME ERROR '424:
OBJECT REQUIRED
When I click on Debugger it leads me to this portion of the code with a highlighted these two lines with an arrow pointing to the second line:
InvestigationsTemplate.AutoTextEntries.Add Name:=rName, _
Range:=rText

HERE IS THE CODE:
Sub AutoTextFromTableAdd()
Dim aTextDoc As Document
Dim cTable As Table
Dim rName As Range, rText As Range
Dim i As Long
Dim sFname As String

sFname = "D:\My Documents\Test\AutotextTable.doc"
Set aTextDoc = Documents.Open(sFname)
Set cTable = aTextDoc.Tables(1)

For i = 1 To cTable.Rows.Count
Set rName = cTable.Cell(i, 1).Range
rName.End = rName.End - 1
Set rText = cTable.Cell(i, 2).Range
rText.End = rText.End - 1

NormalTemplate.AutoTextEntries.Add name:=rName, _
Range:=rText
Next i
aTextDoc.Close wdDoNotSaveChanges
End Sub

Thanks for the time and the help guys; the only other info that I can give is that the template I am currently typing in is the Normal Template; all the other templates are just addons.
Have a great day!
Dave
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference to an external filename which changes frequently roooberta Word 0 12-11-2008 07:33 AM
Calendar entries MISSING - please help brazeagle Outlook 1 01-18-2007 05:17 PM
Help w/ external data bellest Excel 0 11-11-2005 12:51 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:25 PM.


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