template from template

O

Ollie

My business is fond of reorganistations, and recreating corporate templates
each time is becoming a chore. Therefore I want to have a document that I
can design to corporate standards that will collect information from a user
and use that to save a template for future use. The user details simply
round of the particulars for the template. I have a form with some code
that collects the information, writes it to the currennt document in the
required format and then saves the document as a template fior future use.

The code looks like this:

Sub AutoOpen()
'
' This macro collects some user information and creates a template based on
it.
'
Dim strYourName As String
Dim strJobTitle As String
Dim strMyFileName As String
Dim lngPosSpaceChar As Long
Dim strAppUserName As String

'Get the user's name. Use Application Property if not User ID, else collect
name from user
'Look for space char in Application Property as criteria
strAppUserName = Application.UserName

If InStr(1, strAppUserName, " ") = 0 Then
strYourName = InputBox("Please enter your name.")
Else: strYourName = Application.UserName
End If

'Get user's job
strJobTitle = InputBox("Please enter your job title.")

'Write the data to the document
With Selection
.GoTo what:=wdGoToBookmark, Name:="sender"
.TypeText Text:=strYourName
.GoTo what:=wdGoToBookmark, Name:="job"
.TypeText Text:=strJobTitle
.GoTo what:=wdGoToBookmark, Name:="signature"
.TypeText Text:=strYourName
.GoTo what:=wdGoToBookmark, Name:="start"
End With

'Find user's surname and use as file name
lngPosSpaceChar = InStr(1, strYourName, " ")
strMyFileName = Right(strYourName, Len(strYourName) - lngPosSpaceChar)

'Save file as template
ActiveDocument.SaveAs _
FileName:="C:\Documents and Settings\ok23378\Application
Data\Microsoft\Templates\" & _
strMyFileName & ".dot", fileFormat:=wdFormatTemplate

'Alert user
MsgBox ("You now have a personal template." & vbCr & vbCr & "Access it
from File | New")

End Sub

All well and good so far. But the document uses a table to position some
elements on a page, and new documents created with the template the code
creates have the insertion point in the first field of the table. That
isn't where I need it - it needs to be at the point where the user starts to
enter text, identified by a bookmark. I can't see a way to do this.

Any help will be much appreciated.

Ollie
 
J

Jonathan West

Hi Ollie

Include the following macro in the template you create.

Sub AutoNew
On Error Resume Next
ActiveDocument.Bookmarks("StartingPoint").Range.Select
End Sub

Where "StartingPoint" is the name of your bookmark.


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
O

Ollie

Mnay thanks.

Jonathan West said:
Hi Ollie

Include the following macro in the template you create.

Sub AutoNew
On Error Resume Next
ActiveDocument.Bookmarks("StartingPoint").Range.Select
End Sub

Where "StartingPoint" is the name of your bookmark.


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com


starts
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top