P
Peter
Hello everyone,
I am writing some software that I want to distribute to allow people
to easily install in the Word startup folder so it is available
everytime Word is run. The target users are often not very computer
literate and the process I was using was to:
1 distribute a word .doc file (created in 2007 but saved as a .doc
file)
2 get them to confirm that Macros are enabled for this document
3 get themn to click a button which would:
* calculate the path to the startup folder
e.g. c:\documents and settings\evansp\application data\microsoft
\word\startup\dot_installer.dot
* delete the tempate if it had already been installed
* delete the text in the current document
* save the current as a tempate in the startup folder
* ask them to restart word.
This was workng fine but now I am recieving error 4198 when the
tempate is being saved. My questions are:
* why am I receiving error 4198 when the tempate is being saved?
* is there a better way to distribute a tempate for people to install?
* is there a better way to testing to see if macros are enabled?
The code is below and you can also download the document from
http://www.baker-evans.com/community/mod/forum/discuss.php?d=165
thanks in advance for any assistance,
PeterEvans
Public Sub installEMA()
Dim emaDocFile As String
Dim eMADotFile As String
Dim theTempate
Dim thebtns As String
Dim thetitle As String
Dim themessage As String
Dim emaInstalled As Boolean
Dim atemp As Template
Dim mastatus As String
Dim macomputerid As String
Dim madateexpire As Date
Dim dateexpire As Date
Dim newtext As String
Dim origDocument As Document
Dim newDocument As Document
Dim myRange As Range
Dim destfilename As String
'emaDocFile is the name of the doucment we are installing from and
'eMADotFile is the template in the word startup folder we are
going to copy the tempate into
emaDocFile = Application.ActiveDocument.fullname
eMADotFile = Options.DefaultFilePath(wdStartupPath) &
Application.PathSeparator & Application.ActiveDocument.name
If Right$(eMADotFile, 3) = "doc" Then eMADotFile = Left$
(eMADotFile, Len(eMADotFile) - 1) + "t"
If Right$(eMADotFile, 4) = "docm" Then eMADotFile = Left$
(eMADotFile, Len(eMADotFile) - 2) + "tm"
thetitle = "eMarking Assistant will now be installed."
themessage = "Word will be automatically closed once eMarking
Assistant is installed and you should save" & vbCrLf
themessage = themessage & "any unsaved documents before
continuing." & vbCrLf
themessage = themessage & vbCrLf
themessage = themessage & "When you restart Word, you can show the
eMarking Assistant toolbar by:" & vbCrLf
themessage = themessage & "* Word 2003: View menu > Toolbars >
eMarking startup >Show eMarking toolbar" & vbCrLf
themessage = themessage & "* Word 2007: Add-Ins tab > eMarking
group > Show eMarking toolbar" & vbCrLf
themessage = themessage & vbCrLf
themessage = themessage & "Do you want to continue and install
eMarking Assistant now?" & vbCrLf
If MsgBox(themessage, vbYesNo, thetitle) = vbYes Then
'make sure that the current version of ema tempate is deleted
' On Error GoTo errorHandler
' destfilename = "c:\documents and settings\evansp\application
data\microsoft\word\startup\emarking assistant.dot"
' AddIns(destfilename).Installed = False
' SetAttr destfilename, vbNormal
' Kill destfilename
'
'delete the text in the .doc file
' ActiveDocument.Content.Select
' Selection.Delete
' Selection.WholeStory
' Selection.Delete Unit:=wdCharacter, Count:=1
' ActiveDocument.Content.InsertAfter newtext
' save current file as a word template in the startup folder
System.Cursor = wdCursorWait
ActiveDocument.SaveAs FileName:=eMADotFile,
FileFormat:=wdFormatTemplate
' ActiveDocument.Close
'Documents(destfile).Close
'ActiveDocument.Close
'Documents(destfile).Close
'Documents(emaDocFile).Open
Application.ScreenRefresh
thetitle = "eMarking Assistant has been sucessfully
installed."
themessage = "Word will now quit and when you restart Word,
you can show the eMarking Assistant toolbar by:" & vbCrLf
themessage = themessage & "* Word 2003: View menu > Toolbars >
eMarking startup >Show eMarking toolbar" & vbCrLf
themessage = themessage & "* Word 2007: Add-Ins tab > eMarking
group > Show eMarking toolbar" & vbCrLf
themessage = themessage & vbCrLf
themessage = themessage & "Do you want restart Word now?" &
vbCrLf
If MsgBox(themessage, vbOKCancel, thetitle) = vbOK Then
Application.Quit
End If
End If
Exit Sub
errorHandler:
'error handler to catch if a file was beign deleted that does not
exist
Debug.Print "Error # " & Str(Err.Number) & Err.Description
Debug.Print "it must now be deleteted"
Resume Next
End Sub
I am writing some software that I want to distribute to allow people
to easily install in the Word startup folder so it is available
everytime Word is run. The target users are often not very computer
literate and the process I was using was to:
1 distribute a word .doc file (created in 2007 but saved as a .doc
file)
2 get them to confirm that Macros are enabled for this document
3 get themn to click a button which would:
* calculate the path to the startup folder
e.g. c:\documents and settings\evansp\application data\microsoft
\word\startup\dot_installer.dot
* delete the tempate if it had already been installed
* delete the text in the current document
* save the current as a tempate in the startup folder
* ask them to restart word.
This was workng fine but now I am recieving error 4198 when the
tempate is being saved. My questions are:
* why am I receiving error 4198 when the tempate is being saved?
* is there a better way to distribute a tempate for people to install?
* is there a better way to testing to see if macros are enabled?
The code is below and you can also download the document from
http://www.baker-evans.com/community/mod/forum/discuss.php?d=165
thanks in advance for any assistance,
PeterEvans
Public Sub installEMA()
Dim emaDocFile As String
Dim eMADotFile As String
Dim theTempate
Dim thebtns As String
Dim thetitle As String
Dim themessage As String
Dim emaInstalled As Boolean
Dim atemp As Template
Dim mastatus As String
Dim macomputerid As String
Dim madateexpire As Date
Dim dateexpire As Date
Dim newtext As String
Dim origDocument As Document
Dim newDocument As Document
Dim myRange As Range
Dim destfilename As String
'emaDocFile is the name of the doucment we are installing from and
'eMADotFile is the template in the word startup folder we are
going to copy the tempate into
emaDocFile = Application.ActiveDocument.fullname
eMADotFile = Options.DefaultFilePath(wdStartupPath) &
Application.PathSeparator & Application.ActiveDocument.name
If Right$(eMADotFile, 3) = "doc" Then eMADotFile = Left$
(eMADotFile, Len(eMADotFile) - 1) + "t"
If Right$(eMADotFile, 4) = "docm" Then eMADotFile = Left$
(eMADotFile, Len(eMADotFile) - 2) + "tm"
thetitle = "eMarking Assistant will now be installed."
themessage = "Word will be automatically closed once eMarking
Assistant is installed and you should save" & vbCrLf
themessage = themessage & "any unsaved documents before
continuing." & vbCrLf
themessage = themessage & vbCrLf
themessage = themessage & "When you restart Word, you can show the
eMarking Assistant toolbar by:" & vbCrLf
themessage = themessage & "* Word 2003: View menu > Toolbars >
eMarking startup >Show eMarking toolbar" & vbCrLf
themessage = themessage & "* Word 2007: Add-Ins tab > eMarking
group > Show eMarking toolbar" & vbCrLf
themessage = themessage & vbCrLf
themessage = themessage & "Do you want to continue and install
eMarking Assistant now?" & vbCrLf
If MsgBox(themessage, vbYesNo, thetitle) = vbYes Then
'make sure that the current version of ema tempate is deleted
' On Error GoTo errorHandler
' destfilename = "c:\documents and settings\evansp\application
data\microsoft\word\startup\emarking assistant.dot"
' AddIns(destfilename).Installed = False
' SetAttr destfilename, vbNormal
' Kill destfilename
'
'delete the text in the .doc file
' ActiveDocument.Content.Select
' Selection.Delete
' Selection.WholeStory
' Selection.Delete Unit:=wdCharacter, Count:=1
' ActiveDocument.Content.InsertAfter newtext
' save current file as a word template in the startup folder
System.Cursor = wdCursorWait
ActiveDocument.SaveAs FileName:=eMADotFile,
FileFormat:=wdFormatTemplate
' ActiveDocument.Close
'Documents(destfile).Close
'ActiveDocument.Close
'Documents(destfile).Close
'Documents(emaDocFile).Open
Application.ScreenRefresh
thetitle = "eMarking Assistant has been sucessfully
installed."
themessage = "Word will now quit and when you restart Word,
you can show the eMarking Assistant toolbar by:" & vbCrLf
themessage = themessage & "* Word 2003: View menu > Toolbars >
eMarking startup >Show eMarking toolbar" & vbCrLf
themessage = themessage & "* Word 2007: Add-Ins tab > eMarking
group > Show eMarking toolbar" & vbCrLf
themessage = themessage & vbCrLf
themessage = themessage & "Do you want restart Word now?" &
vbCrLf
If MsgBox(themessage, vbOKCancel, thetitle) = vbOK Then
Application.Quit
End If
End If
Exit Sub
errorHandler:
'error handler to catch if a file was beign deleted that does not
exist
Debug.Print "Error # " & Str(Err.Number) & Err.Description
Debug.Print "it must now be deleteted"
Resume Next
End Sub