4120 error just setting Options.Pagination

N

NeilL

I have a Word 2007 VB project that is working fine except on one customer XP
system.

On that system I'm getting several errors that I don't get anyplace else.
The first was an error 13 on the statement

If (Application.Version < 12) Then

I'm not sure why but changing it to

If (Application.Version < "12.0") Then

fixed that one on the customer system.


The one that I can not figure out at all is that I get a 4120 invalid
parameter error on the statement

oAa.Options.Pagination = savePag

The oAa is set to the Word application earlier and the savePag variable is
defined as Boolean and set earlier as in ...

Dim oAa as Object
Dim setpag as Boolean

set oAa = GetObject(, "Word.Application")
savepag = oAa.Options.Pagination

..... more code

oAa.Options.Pagination = savepag 'this fails
oAa.ScreenUpdating = True ' this also fails

I also (in debug on the customer machine) tried to set the value of the
pagination option to a value (False in my test) in the watch window and get
the same 4120 error so I don't think it is a code problem but something else.

I'm guessing there is some policy or permissions thing going on here that I
don't understand. I checked to make sure that the various trust items were
set to the directory where the dotm file lives and the dotm is even signed so
I'm totally stuck.

Any suggestions as to what might be going on here?

Thanks
 
S

Steve Rindsberg

I have a Word 2007 VB project that is working fine except on one customer XP
system.

On that system I'm getting several errors that I don't get anyplace else.
The first was an error 13 on the statement

If (Application.Version < 12) Then

Application.Version returns a string, not a numeric.
VB will try to help even though your code isn't really correct, but if it runs
into strings that don't look like numerics, it gives up and you get a Typ13
error. Example:

Sub Ooopsie()

Dim sMostOfficeVersions As String
Dim sSomeOfficeVersions As String

' Most office versions LOOK like numerics:
sMostOfficeVersions = "12.0"
' Some versions include letters; Office 97 SP1 or 2 for example
sSomeOfficeVersions = "8.1b"

If sMostOfficeVersions > 10 Then
Debug.Print "This works"
End If

If sSomeOfficeVersions > 10 Then
' it'll never do this ... errors on the line above first
Debug.Print "This explodes"
End If

End Sub

Try using

If Int(Val(Application.Version)) < 12
 
N

NeilL

Steve,
Thanks for the reply. I'll give that a try a try.

Any thoughts on the 4120 error?

Thanks
 
S

Steve Rindsberg

Steve,
Thanks for the reply. I'll give that a try a try.

Any thoughts on the 4120 error?


Afraid not. But this also happens on just one or some computers?
 
N

NeilL

It does not fail on my systems and I've not had any other reports of
problems. One specific customer is having issues and I can't figure out the
cause. There may be others who just have not reported the problem but so
far, only one.
 
S

Steve Rindsberg

It does not fail on my systems and I've not had any other reports of
problems. One specific customer is having issues and I can't figure out the
cause. There may be others who just have not reported the problem but so
far, only one.

I'm afraid I don't know what might be causing this.
As you suggest, permissions, macro security ... things I'd check first.
 
L

Luca Brasi

Might it be you have the current Word user name set to an " " (space)?
Someone once mentioned such a bug when setting Word options in VBA.
 

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