Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Run-Time Error

63 views
Skip to first unread message

Steve Z

unread,
Jul 10, 2001, 11:09:13 AM7/10/01
to
I have a series of forms that use an exit macro to populate headers from
form fields. They work just fine when MS Word is maximized. However,
rathern than use Alt-Tab to toggle between screens, some users have resized
MS Word.

When these individuals run the document, on exit from the appropriate field,
they are getting either an illegal operation and shutting down, or they get
a run-time error 5234 with a message saying the window is too small.

While the work-around is simple (run maximized and toggle), they would
really like to be able to see both screens at once.

Any thoughts on what would be causing this? The bookmarks are valid, the
fields are properly populated, has anyone heard of MS Word causing a
run-time error based on the size of the window?

Thanks for any advice.


Michael

unread,
Jul 10, 2001, 7:01:44 PM7/10/01
to
can you show us the code you're using to put info in the headers?

"Steve Z" <szu...@govmail.state.nv.us> wrote in message
news:Oy65nIVCBHA.576@tkmsftngp02...

Steve Z

unread,
Jul 11, 2001, 11:11:59 AM7/11/01
to
I know this is cumbersome, but it works, so I try not to mess with it too
much (I'm self-taught)

If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If

If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Or
ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.TypeText Text:="Claimant Name: "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Name"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeParagraph
Selection.TypeText Text:="Social Security Number: "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="SSN"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeParagraph
Selection.TypeText Text:="Adj: "
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Adj"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With

ActiveDocument.FormFields("ClaimantName").Select
Selection.Copy
If ActiveDocument.Bookmarks.Exists("Name") = True Then
ActiveDocument.Bookmarks("Name").Select
Selection.PasteSpecial DataType:=wdPasteText
Else
End If

ActiveDocument.FormFields("ClaimantSSN").Select
Selection.Copy
If ActiveDocument.Bookmarks.Exists("SSN") = True Then
ActiveDocument.Bookmarks("SSN").Select
Selection.PasteSpecial DataType:=wdPasteText
Else
End If

ActiveDocument.FormFields("ClaimantADJ").Select
Selection.Copy
If ActiveDocument.Bookmarks.Exists("Adj") = True Then
ActiveDocument.Bookmarks("Adj").Select
Selection.PasteSpecial DataType:=wdPasteText
Else
End If
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If

As I said, I'm just curious why the run-time comes up. I realize object
programming and setting a range is probably more effective, tighter and
neater, I just haven't been able to get that approach to produce the desired
results.

Thanks!

"Michael" <mp...@connexus.net.au> wrote in message
news:Ow$ywPZCBHA.1784@tkmsftngp02...

Dave Rado

unread,
Jul 12, 2001, 8:56:17 AM7/12/01
to
Hi Steve

Not only is going into the Headers/Footers cumbersome, but it also causes
the problem you're reporting, if the window is too small.

The best way to update the Header is like this:

With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
.Range.Text = "Claimant Name: " & vbCr & "Social Security Number: " _
& vbCr & "Adj: "
End With

With regard to the rest of your code, I'm confused about several things:

1) Why are you creating the entire header through code rather than create it
in your template at design time, which is how this sort of thing is usually
done?

2) Why are you using paste link, rather than using a REF field, which again,
is how it's usually done - e.g.:
{ Ref "ClaimantName" \* CharFormat }

3) Why the need for the bookmarks in the Header? You can just refer to the
paragraph numbers in any subsequent macro, e,g.

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary) _
.Range.Paragraphs(3).Range.InsertAfter "Hello World"

Regards

Dave

"Steve Z" <szu...@govmail.state.nv.us> wrote in message

news:#YWi2uhCBHA.1480@tkmsftngp05...

Steve Z

unread,
Jul 12, 2001, 1:41:14 PM7/12/01
to
This is where this forum is an incredible place. As I said, I am self
taught, have taken no programming classes and am in an untenable position of
having to "trial and error" create things. Unfortunately, as a public
employee working for an agency on a limited budget, there are really no
funds to train me properly, nor enough staff to get the job done without
impressing rookies like me into service.

Thanks for the info, I'll work with the tidbits you passed on and see if I
can make this a much better macro. Thanks again!

"Dave Rado" <dr...@onetel.net.uk> wrote in message
news:#vjaWJtCBHA.2080@tkmsftngp07...

Dave Rado

unread,
Jul 12, 2001, 1:59:04 PM7/12/01
to
Hi Steve

If you get any spare time, it's also well worth looking though tha artcles
in the Macros/VBA tab of http://www.mvps.org/word/FAQs/.

Regards

Dave

"Steve Z" <szu...@govmail.state.nv.us> wrote in message

news:ODz1AnvCBHA.1536@tkmsftngp07...

Mark Tangard

unread,
Jul 12, 2001, 10:55:20 PM7/12/01
to

Steve Z,

> I am self taught, have taken no programming classes and am in an
> untenable position of having to "trial and error" create things.
> Unfortunately, as a public employee working for an agency on a
> limited budget, there are really no funds to train me properly,

Some of us have no formal training either. And sometimes it shows.

One good rule of thumb when you're trying to write code that's 'over
your head' is this: If, when you try recording it, you get monstrous
amounts of code to do what you think should be a simple task, and
especially if contains copious use of the Selection object, it's
usually something that can be coded much more simply with a totally
different approach that the recorder, by its very nature, can't
duplicate. Often this just involves using Ranges, or even (as in
parts of this case, evidently), just tweaking the template itself,
without using macros at all.

-- Mark Tangard <mtan...@speakeasy.net> ----------------------------
------ WWW: http://www.speakeasy.org/~mtangard ----------------------
------------- "Life is nothing if you aren't obsessed." --John Waters
---------------------------------------------------------------------

0 new messages