Little expertise is needed, just perseverance! I am a lawyer, not a
programmer.
You need to clearly think through what it is you want in advance though.
For instance, using insertion of text from another file, I keep my inserted
material in document files in a subfolder of the workgroup templates folder
named Parts. I then have my code determine what folder this is on-the-fly.
That way when servers are changed or computer configurations are changed,
the code does not need to be changed.
Here is a sample of that code.
Sub AutoNew()
'
' AutoNew Macro loads pleading header and then goes to first field
' AutoNew Macro written 22 September 2000 by Charles Kyle Kenyon
' Revised 11 September 2002 by Charles Kyle Kenyon
' Copyright 2000,2002 Charles Kyle Kenyon all rights reserved
'
' Needs document in Workgroup templates folder "Parts" named
' PleadingParts.doc with header text and graphics in bookmark
'
On Error Resume Next
Dim sWorkgroup As String ' holder for workgroup templates path
'
' Get workgroup templates path
'
sWorkgroup =
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath)
'
' Show hidden text
'
Application.Run MacroName:="HiddenTextViewNoPrint" 'Show hidden text
instructions
'
Selection.HomeKey Unit:=wdStory ' Go to beginning of document
' Make sure not using split screen and am in PrintView mode
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader 'Go into
document Header
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1 'Delete current header
'Insert header form from PleadingParts.doc bookmarked range
Selection.InsertFile FileName:=sWorkgroup & "\Parts\PleadingParts.doc",
Range:="PleadingHeader", _
ConfirmConversions:=False, Link:=False, Attachment:=False
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument 'Close header
Selection.HomeKey Unit:=wdStory ' Go to beginning of document
Selection.NextField.Select 'Go to first field
End Sub
The portion
Range:="PleadingHeader"
refers to a bookmark in the source document.
Alternatively, you could save the material as AutoText in a global template.
http://addbalance.com/word/movetotemplate.htm Use AutoText fields in the
recipient document to get that material and an AutoNew macro to first
refresh the field and then unlink it. (That way a new document has the
latest information and that information is fixed for that document - it will
not change if the AutoText changes in the future.)
Sub AutoNew()
' Written by Charles Kyle Kenyon 19 June 2006
' All Story Field Updater/Unlinker - AutoText fields
Dim oField As Field
Dim oStory As Range
' On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldAutoText Then
oField.Update
oField.Unlink
End If
Next oField
Set oStory = oStory.NextStoryRange
Loop Until oStory Is Nothing
Next oStory
End Sub
You may want to also look at
http://word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm. Although it is
about distributing macros (these macros go into document templates), the
same principles apply to distributing AutoText (which I would keep in a
global template).
http://addbalance.com/usersguide/templates.htm
Hope this helps.
--
Charles Kenyon
Word New User FAQ & Web Directory:
http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
http://addbalance.com/usersguide
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.