Templates with UserForms

A

Angie M.

Hi,

I'm using Word 03. I have a collection of Word templates which contain
UserForms. They work well on most of the computers, however there are 3
computers, that when the user tries to create a new doc based on the
template, the userform does not appear, only the template. So instead of
getting the form where they would fill in their info, they are taken directly
into the document. So basically the code is not running. I've checked their
macro security settings, both "trust" checkboxes are checked on the Trust tab
and macro security is on Low. I've replaced their Normal templates and
checked other settings - nothing seems amiss. Any ideas? Thanks!
 
W

Word Heretic

G'day Angie M. <[email protected]>,

See if those puters have Word add-ons that the others dont - you may
be getting some interference from them.


Steve Hudson - Word Heretic

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


Angie M. reckoned:
 
A

Angie M.

Hi,

Thanks for your response. I actually temporarily removed the two addins,
Workshare and Adobe. Any other ideas? Thanks
 
C

Charles Kenyon

Did removing those Add-Ins make any difference? It is possible you have
more, even if not in the startup folder.
--
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.
 
A

Angie M.

Thanks for responding. No, it didn't make any difference. Have you ever
seen code just simply not run? Here's the code by the way, but all the
templates I have that contain Document_New events do the same thing on a few
particular computers - the code doesn't execute.


Private Sub Document_New()

Dim oDoc As Document
Dim nListIndex As Long
Dim nCurrRecord As Long
Dim sName As String
Dim sType As String
Dim sPhone As String
Dim sFax As String
Dim sEmail As String
Dim sRecipient As String
Dim sAddress As String
Dim sRegarding As String
Dim sSalutation As String
Dim nLineCount As Long
Dim bUnderline As Boolean
Dim bBold As Boolean
Dim bItalic As Boolean
Dim nStart As Integer
Dim nNext As Integer

Dim ofrmSelect As frmSelect
Set ofrmSelect = New frmSelect

Set oDoc = ActiveDocument

Load ofrmSelect

ofrmSelect.optNone = True
ofrmSelect.lstLawyers.Clear
If ofrmSelect.cmdCancel = True Then ActiveDocument.Close wdDoNotSaveChanges
DoEvents

oDoc.MailMerge.DataSource.ActiveRecord = wdFirstRecord

Do
ofrmSelect.lstLawyers.AddItem
oDoc.MailMerge.DataSource.DataFields("Name")
nCurrRecord = oDoc.MailMerge.DataSource.ActiveRecord
oDoc.MailMerge.DataSource.ActiveRecord = wdNextRecord
Loop Until nCurrRecord = oDoc.MailMerge.DataSource.ActiveRecord

ofrmSelect.lstLawyers.ListIndex = -1
ofrmSelect.Show


If ofrmSelect.optCertified = True Then
ActiveDocument.Bookmarks("bkdelivery").Range.Text = "Via Certified Mail;
Return Receipt Requested"
End If

If ofrmSelect.optFacUS = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via Facsimile and U.S. Mail"
End If

If ofrmSelect.optHand = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via Hand Delivery"
End If

If ofrmSelect.optFacsimile = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via Facsimile"
End If

If ofrmSelect.optUPS = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "VIA UPS"
End If

If ofrmSelect.optFedex = True Then
oDoc.Bookmarks("bkdelivery").Range.Text = "Via FedEx"
End If

ActiveDocument.Bookmarks("bkRe").Range.Text = ofrmSelect.txtRe
ActiveDocument.Bookmarks("bkSalutation").Range.Text =
ofrmSelect.txtSalutation
ActiveDocument.Bookmarks("bkRecName2").Range.Text = ofrmSelect.txtRecName


If ofrmSelect.boxPaste = True Then
On Error GoTo ErrHandler
ActiveDocument.Bookmarks("bkRecName").Range.PasteAndFormat wdPasteDefault

End If


ErrHandler:
If Err.Number = 4605 Then
MsgBox "The clipboard is empty. You must first select and copy text."


End If


If ofrmSelect.boxOutlook = True Then

Selection.GoTo what:=wdGoToBookmark, Name:="bkRecName"

WordBasic.InsertAddress


Selection.Delete Unit:=wdCharacter, Count:=1

Selection.GoTo what:=wdGoToBookmark, Name:="bkStop"
End If

If ofrmSelect.optNone = True Then
With ActiveDocument.Bookmarks("bkDelivery")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With

End If




If ofrmSelect.txtRecFirm.Text = "" Then
With ActiveDocument.Bookmarks("bkRecFirm")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkRecFirm").Range.Text =
ofrmSelect.txtRecFirm.Text
End If



If ofrmSelect.txtAdd1.Text = "" Then
With ActiveDocument.Bookmarks("bkAdd1")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkAdd1").Range.Text = ofrmSelect.txtAdd1.Text
End If



If ofrmSelect.txtAdd2.Text = "" Then
With ActiveDocument.Bookmarks("bkAdd2")
.Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkAdd2").Range.Text = ofrmSelect.txtAdd2.Text
End If

If ofrmSelect.txtCityStateZip.Text = "" Then
With ActiveDocument.Bookmarks("bkCityStateZip")
' .Range.Paragraphs(1).Range.Delete
.Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkCityStateZip").Range.Text =
ofrmSelect.txtCityStateZip.Text
End If


If ofrmSelect.txtcc.Text = "" Then
With ActiveDocument.Bookmarks("bkcc")
.Range.Paragraphs(1).Range.Delete
' .Delete ' remove the bookmark itself, too
End With
Else
ActiveDocument.Bookmarks("bkcc").Range.Text = ofrmSelect.txtcc.Text
End If


If ofrmSelect.txtbcc.Text = "" Then
With ActiveDocument.Bookmarks("bkbcc")
.Range.Paragraphs(1).Range.Delete
' .Delete ' remove the bookmark itself, too
End With
Else


Selection.GoTo what:=wdGoToBookmark, Name:="bkBCC"
Selection.HomeKey Unit:=wdLine
Selection.InsertBreak (wdPageBreak)
Selection.TypeParagraph


ActiveDocument.Bookmarks("bkbcc").Range.Text = ofrmSelect.txtbcc.Text
End If


ActiveDocument.Bookmarks("bkRecName").Range.Text =
ofrmSelect.txtRecName.Text


If ofrmSelect.mReturn Then

nListIndex = ofrmSelect.lstLawyers.ListIndex

Unload ofrmSelect

Set ofrmSelect = Nothing
'Unload ofrmSelect
End If

If nListIndex <> -1 Then
oDoc.MailMerge.DataSource.ActiveRecord = nListIndex + 1

sName = oDoc.MailMerge.DataSource.DataFields("Name")
sType = oDoc.MailMerge.DataSource.DataFields("Title")
sPhone = oDoc.MailMerge.DataSource.DataFields("DD")
sFax = oDoc.MailMerge.DataSource.DataFields("Fax")
sEmail = oDoc.MailMerge.DataSource.DataFields("Email")


End If

ActiveDocument.Bookmarks("bkName").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Name")
ActiveDocument.Bookmarks("bkDD").Range.Text =
oDoc.MailMerge.DataSource.DataFields("DD")
ActiveDocument.Bookmarks("bkEMail").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Email")
ActiveDocument.Bookmarks("bkFax").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Fax")
ActiveDocument.Bookmarks("bkSig").Range.Text =
oDoc.MailMerge.DataSource.DataFields("Sig")




nStart = 1
Do
nNext = InStr(nStart, sAddress, Chr(13), vbBinaryCompare)
nLineCount = nLineCount + 1
nStart = nNext + 1
Loop Until nNext = 0
oDoc.Range.InsertAfter (sAddress & Chr(13))

Selection.MoveUntil Chr(9), wdForward
Selection.Expand wdParagraph


oDoc.MailMerge.MainDocumentType = wdNotAMergeDocument
Set oDoc = Nothing



Selection.GoTo what:=wdGoToBookmark, Name:="bkStop"




End Sub
 
C

Charles Kenyon

Again, you can have other Add-ins.
http://word.mvps.org/FAQs/Customization/CheckIfAddinsInstalled.htm
Check that first because it is the most likely cause of problems you are
seeing.
Check this on the computer where your code is not running.
--
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.
 
W

Word Heretic

G'day Angie M. <[email protected]>,

As a very generic test, create a new Normal, create a template based
on it, stick in a Document_New() with Msgbox "yeah baby" in it, and
send that off to the users for testing. If that fails, we have some
sort of anti-virus treatment getting in our road.


Steve Hudson - Word Heretic

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


Angie M. reckoned:
 
Top