easy install of template (saveas fileformat:=WDformattempate) ERRO

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
 
R

red6000

I'm doing a similar thing, achieved with sitting in the autoopen of a word
doc:


On Error Resume Next
Application.OrganizerDelete Source:= _
"Y:\Templates\normal.dot", Name:= _
"UpdateCfel", Object:=wdOrganizerObjectProjectItems
Application.OrganizerCopy Source:= _
"J:\Protection-Customer-Service\Customer Correspondence\APA
14-04-05.dot", _
Destination:= _
"Y:\Templates\normal.dot", Name:= _
"UpdateCfel", Object:=wdOrganizerObjectProjectItems



On Error Resume Next
Application.OrganizerDelete Source:= _
"Y:\Templates\normal.dot", Name:= _
"UserForm1", Object:=wdOrganizerObjectProjectItems
Application.OrganizerCopy Source:= _
"J:\Protection-Customer-Service\Customer Correspondence\APA
14-04-05.dot", _
Destination:= _
"Y:\Templates\normal.dot", Name:= _
"UserForm1", Object:=wdOrganizerObjectProjectItems
 

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