Reference Memory

J

Jason

Hi,

I am currently using Windows 2002 and am working on a
template that uses two different templates with 3 autonew
userforms. When I test this template on my computer, it
works fine (isn't that what they all say?), but when a few
of my users try it at their own computers, they get a
referred or reference memory error and then followed by a
windword.exe that shuts Word down. I am thinking maybe I
have a memory leak or something like that in my code, but
I am not sure where.

The first macro consists of three userforms that allow the
user to enter data that is then inserted into the each
page in the template.

The second macro takes a text file stored in a certain
location, removes line breaks and other garbage and
converts it into a comma-delimited file that can be safely
merged with the template.

I would be glad to show the code if anyone needs to see
it. Does anyone have any ideas what's going on?

TIA,
Jason
 
M

martinique

Do all your users have exactly the same versions of Word and Windows. The
errors you're getting are typical of the problems with clashing file
versions (eg, if your users have earlier versions of the UserForm DLLs).
 
J

Jason

I will paste the code that runs when they open the
template.

Sub autonew()
'
' autonew Macro
' Macro created 7/18/2003 by jlogue
'
UserForm1.Show

UserForm2.Show

UserForm3.Show

ChangeFileOpenDirectory "Q:\IS\Contracts\PSA
Processing\Downloads\"
Documents.Open FileName:="fis0001d.txt",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="",
Format:=wdOpenFormatAuto, Encoding:=1252
Application.Run Macroname:="contracts"
ActiveWindow.Close
ActiveDocument.MailMerge.OpenDataSource Name:= _
"Q:\IS\Contracts\PSA
Processing\Downloads\Contractdownload.doc", _
ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="",
WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:="",
SQLStatement:="", SQLStatement1 _
:="", SubType:=wdMergeSubTypeOther
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With



End Sub

And here is the Contracts code that's referenced above:

Sub contracts()
'
' contracts Macro
' Macro recorded 7/25/2003 by jlogue
'
Selection.EndKey Unit:=wdStory
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ","
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ","
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.EndKey Unit:=wdStory
Selection.TypeBackspace
Selection.HomeKey Unit:=wdStory
Selection.InsertFile FileName:="Q:\IS\Contracts\PSA
Processing\Fields\fields.doc", Range:="",
ConfirmConversions _
:=False, Link:=False, Attachment:=False
ActiveDocument.SaveAs
FileName:="Contractdownload.doc", FileFormat:= _
wdFormatDocument, LockComments:=False,
Password:="", AddToRecentFiles:= _
True, WritePassword:="",
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False,
SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub

TIA,
Jason
 
J

Jason

Thank you for candid nature. I am glad my organization
doesn't classify me as a programmer. Most of the code was
recorded which could explain its "ugly" appearance. I am
not sure about the other questions in your response.
-Jason
 
J

Jason

Got it fixed.
-----Original Message-----
Martinique, et al,

If it will help, we are all using MS Word 2002 SP 2. This
error occurs in the last part of the process. The
userforms have appeared, the merge data is retrieved and
is in the process of merging with the shell document when
it crashes or gives me the error. I tried to clean up my
code. It now looks like this:



Sub autonew()
'
' autonew Macro
' Macro created 7/18/2003 by jlogue
'
UserForm1.Show

UserForm2.Show

UserForm3.Show

ChangeFileOpenDirectory "Q:\IS\Contracts\PSA
Processing\Downloads\"
Documents.Open FileName:="fis0001d.txt"
Application.Run Macroname:="contracts"
ActiveWindow.Close
ActiveDocument.MailMerge.OpenDataSource
Name:="Q:\IS\Contracts\PSA
Processing\Downloads\Contractdownload.doc"
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With


End Sub
Sub contracts()
'
' contracts Macro
' Macro recorded 7/25/2003 by jlogue
'
Selection.EndKey Unit:=wdStory
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeBackspace
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ","
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = ","
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.EndKey Unit:=wdStory
Selection.TypeBackspace
Selection.HomeKey Unit:=wdStory
Selection.InsertFile FileName:="Q:\IS\Contracts\PSA
Processing\Fields\fields.doc", Range:="",
ConfirmConversions _
:=False, Link:=False, Attachment:=False
ActiveDocument.SaveAs FileName:="Contractdownload.doc"
End Sub


TIA,
Jason

.
 

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