Code runs correctly on some computers but not others

H

headly

Creating code in Word 03 to run on XP computers. The code runs flawlessly on
some machines and errors out on others. Macro security aside, any ideas why
this would happen? Could it be the machines need service packs? Coherent
thoughts appreciated. Thx
 
J

Jay Freedman

Creating code in Word 03 to run on XP computers. The code runs flawlessly on
some machines and errors out on others. Macro security aside, any ideas why
this would happen? Could it be the machines need service packs? Coherent
thoughts appreciated. Thx

If you're using references to specific libraries, those files might
not be present on all the other computers.

On a computer where the code doesn't run, open the VBA editor and look
at Tools > References. If any of the checked items are marked as
missing, you need to install the necessary dll or ocx. You may also
need to run regsvr32 on the dll or ocx to register it.
 
J

Jonathan West

In addition to Jay's answer, look at the following

- if the macro looks up files in specific locations, are they in the same
place on all machines

- Are the settings the same in the Options dialog on all machines? For
instance, if the Save options include omitting featureslater than Word 97,
you will have trouble with nested tables and with text colors

The thing to do is to run the code on the various offending machines, and
see exactly where it breaks. If you can't go there yourself, produce what I
cann an "instrumented" version of your template that writes information to a
log file of where it has got to. Get the user to run the program and send
back the log.
 
H

headly

So I wrote a simple on-exit forms procedure below. It ran fine on Office 11,
but hung on some Office 10 computers. When I saw the setup, I noted that the
problem computer had SP1 (rev 10.37xx) whereas the others did not have SP1
(rev 10.26xx). The Follow Up Question: If I write a packager/installer in
Vstudio, isn't it dangerous to overwrite someones dlls? If I write the code
in Office 9, would that avoid the issue? I'd love to know what MSFT thinks
about this one.

Sub TestEOS()

Dim varFieldResult As Variant
Dim intTableLine As Integer

On Error Resume Next

Call UnProtectDocument

Application.ScreenUpdating = False

varFieldResult =
ActiveDocument.Bookmarks("bkmHotelLodgeLine").Range.FormFields.Item("bkmHotelLodgeLine").Result

If varFieldResult = "End of Service" Or varFieldResult = "End of Services"
Or varFieldResult = "End Of Service" Or varFieldResult = "End Of Services" Or
varFieldResult = "end of service" Or varFieldResult = "End of service" Or
varFieldResult = "end of services" Or varFieldResult = "End of services" Then
Selection.GoTo What:=wdGoToBookmark, Name:="bkmDatePrepP4"
End If

'Housekeeping/Cleanup
Call ProtectDocument
Application.ScreenUpdating = True

End Sub
 
J

Jonathan West

Hi headly,


You should not under any circumstances create an installer that updates
Office DLLs. Two reasons for this. First of all, you may well break the
user's copy of Office if the DLLs are not fully aligned, as they would be if
the copy is updated using a proper Service Pack. Second, you probably would
be in breach of license conditions to redistribute the individual DLLs.

The fact that the bad machine has SP1 installed is not *necessarily* the
cause of the problem. The existence of correlation does not mean that there
is definitely a causal relationship. As far as I can tell, you haven't yet
identified where in the code the hang occurs. Until you do that, you cannot
make more progress on identifying the cause. You will need to produce a
version of the macro that writes its progress to a log file so you can
pinpoint the exact line of code which causes the hang. Unless you do that,
and tell us which line it is, there is little more that anybody here will be
able to do to help.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
 

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