simple install a template (saveas fileformat:=wdformattemplate) ER

P

Peter

Hello everyone,

I am working on distributing a VBA utility an want to distribute in the
easest possible way for people to install and use.

I would like to distribute it as a single Word .DOC file that will contain
both the documentation and the VBA. The document will contain buttons to
install the code in the .../WORD/STARTUP folder and also uninstall it. The
utilility will be launched by a toolbar button.

The fall back method (which is working) to distribute it as a .DOC (with
document and Install button) and a seperate .DOT file.

The install code is given below but there is a problem (isn't there always).

1. It will run correctly if I click the RUN button in the VBA editor but if
I click a button in the document I get a "Runtime eror 4198. Cpommand failed"

2. Sometimes, when Word is restarted I get a message saying that the
template in the STARTUP folder is "not valid"

Does anyone have any suggestions on how to get around this problem so I
distribute a single file.

Thanks in anticipation of receiving lots of helpful suggestions,
Peter
http://members.dodo.com.au/bakerevans/

------
Sub install()
Dim destfile As String
Dim sourceFile As String
Dim thisfile As String
Dim theMessage

theMessage = "Do you want to install Word Purge?" & vbCrLf
If MsgBox(theMessage, vbYesNo) = vbYes Then

'name of this file
thisfile = Application.ActiveDocument.FullName

destfile = Options.DefaultFilePath(wdStartupPath) & _
Application.PathSeparator & "Word Purge.dot"

sourceFile = Application.ActiveDocument.Path & _
Application.PathSeparator & "Word Purge.dot"

ActiveDocument.SaveAs FileName:=destfile, _
FileFormat:=wdFormatTemplate

End If
end sub
 
W

Word Heretic

G'day "Peter" <[email protected]>,

Problem: When users upgrade they cant copy the file over an existing
one because Word has loaded and locked the add-ins in.

My Solution: Word template loads, dumps the names of the dirs needed
into a copy instruction, we exit word, our batch file calls the text
file we just made to copy the files whilst Word is closed.


Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Peter reckoned:
 

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