Peter
Mon Nov 17 04:07:25 CST 2003
Hello Jonathan
You were right. I transferred enough of the routine, including the element
which always causes the crash, to a new module in a new document, and
stepped through it. It worked just fine, which leaves me with a bit of a
headache regarding the original module. It is one of a dozen in a template
which also has about a dozen user forms. Do I have to recreate them all, or
will a simple export/re-import work to solve the problem. I can't see
anything wrong with the code, and it still works in Word 97 on Win 20000, so
I'm hoping you'll say "export and import."
Best wishes
Peter Kessler
Kessler Associates
E: ka@kessler-web.co.uk
W:
http://www.kessler-web.co.uk
"Jonathan West" <jwest@mvps.org> wrote in message
news:#6rjoFhqDHA.2440@TK2MSFTNGP10.phx.gbl...
> Hi Peter,
>
> Its possible that there is some corruption in the template. Try copying
the
> code out of the template into a new one, and running it from there.
>
> --
> Regards
> Jonathan West - Word MVP
>
http://www.multilinker.com
> Please reply to the newsgroup
>
> "Peter L Kessler" <plk.ka@tesco.net> wrote in message
> news:%23AT4rygqDHA.964@TK2MSFTNGP10.phx.gbl...
> > Hi "z"
> >
> > I'd almost given up on getting an answer! The routine's registry entries
> > contain previously save printer and tray settings. These are read back
in
> so
> > that the user only has to set these once.
> >
> > The OS that's installed on the problem PCs is Win XP (running Word
2002).
> > The routine always worked on Win 2000, with Word 97 or 2000.
> >
> > The routine already has error checking, but when Word 2002 crashes the
> whole
> > programme goes, not the routine. Word itself crashes and prompts to send
> > Microsoft an error report each time. The error checking doesn't seem to
> get
> > a chance to run.
> >
> > Best wishes
> > Peter Kessler
> >
> > Kessler Associates
> > E: ka@kessler-web.co.uk
> > W:
http://www.kessler-web.co.uk
> >
> >
> >
> >
> >
> >
> > "z" <anonymous@discussions.microsoft.com> wrote in message
> > news:0acc01c3a7d8$e30d73b0$a001280a@phx.gbl...
> > > I'm a little confused what exactly the registry entries
> > > contain. You didn't specify if the OS was changed also,
> > > but try inserting some error checking and verify that the
> > > registry setting came in correctly:
> > >
> > > On Error Goto Problem
> > > ' Set Tray 1 for Page 1
> > > If cboInvTray1 <> "" Then
> > > With Options
> > > .DefaultTray = cboInvTray1
> > > 'crashes here
> > > End With
> > >
> > > Problem:
> > >
> > > Msgbox cboInvTray1
> > > Exit Sub
> > >
> > > >-----Original Message-----
> > > >Hello
> > > >
> > > >I've been maintaining a set of Word VBA macros for a few
> > > years at the
> > > >office, and have a routine which prints the current
> > > document to a pre-set
> > > >printer and tray(s). The pre-sets have been saved in the
> > > Registry, so the
> > > >routine pulls these out and uses them to reset the
> > > ActivePrinter, print the
> > > >document and then reset the ActivePrinter from saved data.
> > > >
> > > >This works fine for Word 97 (on Win 98 & 2000) and Word
> > > 2000 (Win2000 & XP).
> > > >Word 2002 (Win XP) crashes completely (not just a VBA
> > > error, but Word
> > > >itself) when it reaches the line which alters the
> > > DefaultTray to the saved
> > > >setting. I have pasted the essential elements of the
> > > routine below. I'm
> > > >hoping someone will be able to tell me why this is
> > > happening with the "new
> > > >and improved" Word, when the old versions work quite
> > > happily with it. Any
> > > >help is greatly appreciated.
> > > >
> > > >Best wishes
> > > >Peter Kessler
> > > >
> > > >Kessler Associates
> > > >E: digital@kessler-web.co.uk
> > > >W:
http://www.digital.kessler-web.co.uk
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >Public PrintDocument()
> > > >
> > > >Dim SelectedComboBox As String
> > > >
> > > > 'Get the saved printer and tray settings
> > > from the Registry
> > > > cboCInvPrint1 =
> > > System.PrivateProfileString("", lsection,
> > > >"CInvPrint1")
> > > > cboCInvPrint2 =
> > > System.PrivateProfileString("", lsection,
> > > >"CInvPrint2")
> > > > cboCInvTray1 = System.PrivateProfileString
> > > ("", lsection,
> > > >"CInvTray1")
> > > > cboCInvTray2 = System.PrivateProfileString
> > > ("", lsection,
> > > >"CInvTray2")
> > > >
> > > > SelectedComboBox = cboInvPrint1
> > > > ComboBoxChange
> > > >
> > > > ' Set Tray 1 for Page 1
> > > > If cboInvTray1 <> "" Then
> > > > With Options
> > > > .DefaultTray =
> > > cboInvTray1 '******************** Word
> > > >crashes here
> > > > End With
> > > >
> > > > 'Routine then prints page 1...
> > > >
> > > >End Sub
> > > >
> > > >Public ComboBoxChange()
> > > > With Dialogs(wdDialogFilePrintSetup)
> > > > .Printer = SelectedComboBox
> > > > .DoNotSetAsSysDefault = True
> > > > .Execute
> > > > End With
> > > >End Sub
> > > >
> > > >
> > > >
> > > >.
> > > >
> >
> >
>