Custom Forms script error

  • Thread starter Bryan Dickerson
  • Start date
B

Bryan Dickerson

I'm trying to disable a command bar that has occassionally caused problems
in a custom form. I came up with this routine:

Sub SetCmdBars(ByVal boolVal)
Dim oF
Dim oCB

Set oF = Item.GetInspector
For Each oCB in oF.CommandBars
If oCB.Name = "Standard" Then
oCB.Enabled = boolVal
oCB.Visible = boolVal
End If
Next
oF.CommandBars("View").Enabled = boolVal
oF.CommandBars("Tools").Enabled = boolVal
oF.CommandBars("Actions").Enabled = boolVal
End Sub

.... and some users are getting the error message:
"You don't have appropriate permission to perform this operation." and the
line number points to the script code line: "Set oF = Item.GetInspector".

Anyone have any ideas?

Thanx!
 
G

Guest

Where is the code that declares the Item object?

It obviously sounds like a permissions problem; does the user have read
access to the folder that contains the Item you are setting a reference to?
 
B

Bryan Dickerson

Item refers to the Outlook Task Item that is available to the script when it
runs. Since this form runs in a folder where each user has rights to create
and alter most anything about the individual tasks, I would have to assume
(I know dangerous) that the user could modify the Item object. But that may
be a very faulty assumption. Are there any docs that you could point me to?
 
G

Guest

Sorry - I didn't realize you were talking about a custom form, where of
course the Item object is intrinsic!

I can't imagine why you'd get a permissions error on retrieving the
Inspector object, even if the user only had read permissions - nothing is
getting modified, and you can't really alter an item from the Inspector
object anyway.

You might want to verify the permissions for those users who are receiving
these errors, and note their Outlook version as well. Otherwise, I'm stumped.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
B

Bryan Dickerson

I just looked at the public folder whence the custom forms are being run.
The permissions are correct and there are no exceptions. Outlook version is
something I've been fighting hard for, but I'm fairly sure that all these
users are at OL 2003 SP1. That is the latest, right?
 
B

Bryan Dickerson

I'm calling it in Item_Open
SetCmdBars False
.... and in Item_Close
SetCmdBars True.

And the users report that it's mostly on the SetCmdBars True call that they
are seeing the errors. I tried setting oF =
Item.GetInspector.ModifiedFormPages.Add("Ticket") (I'm not sure what that
does exactly, but it works to access the Custom Form User Properties) but it
only caused more errors.
 
B

Bryan Dickerson

So can you not set properties of Item.GetInspector if you don't have a
certain authorization?
 
G

Guest

An Inspector object doesn't directly expose the properties of the underlying
Outlook item, whether Task, Contact, e-mail, etc. It's basically a wrapper
for the form that displays the content, with properties for window size,
caption, etc. - the "window dressing".

Also, you don't really need to re-enable the commandbars when the item
closes - Outlook resets the commandbars whenever the next item opens - so you
can get rid of the code in the Item_Close event.

The ModifiedFormPages method is mainly used to retrieve the Controls
collection for a particular page on your custom form. You can always access
custom fields through the Item.UserProperties collection.

Regardless, just include some error handling to bypass this error anyway:

Sub SetCmdBars(ByVal boolVal)
On Error Resume Next

Dim oF
Dim oCB

Set oF = Item.GetInspector
If Err.Number <> 0 Then Exit Sub 'Problem!
For Each oCB in oF.CommandBars
If oCB.Name = "Standard" Then
oCB.Enabled = boolVal
oCB.Visible = boolVal
End If
Next
oF.CommandBars("View").Enabled = boolVal
oF.CommandBars("Tools").Enabled = boolVal
oF.CommandBars("Actions").Enabled = boolVal
End Sub


--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
B

Bryan Dickerson

Thanx. I'll give it a whirl! I can just see the scowl on my boss' face
when I tell him the solution was: "On Error Resume Next"!!

Eric Legault said:
An Inspector object doesn't directly expose the properties of the
underlying
Outlook item, whether Task, Contact, e-mail, etc. It's basically a
wrapper
for the form that displays the content, with properties for window size,
caption, etc. - the "window dressing".

Also, you don't really need to re-enable the commandbars when the item
closes - Outlook resets the commandbars whenever the next item opens - so
you
can get rid of the code in the Item_Close event.

The ModifiedFormPages method is mainly used to retrieve the Controls
collection for a particular page on your custom form. You can always
access
custom fields through the Item.UserProperties collection.

Regardless, just include some error handling to bypass this error anyway:

Sub SetCmdBars(ByVal boolVal)
On Error Resume Next

Dim oF
Dim oCB

Set oF = Item.GetInspector
If Err.Number <> 0 Then Exit Sub 'Problem!
For Each oCB in oF.CommandBars
If oCB.Name = "Standard" Then
oCB.Enabled = boolVal
oCB.Visible = boolVal
End If
Next
oF.CommandBars("View").Enabled = boolVal
oF.CommandBars("Tools").Enabled = boolVal
oF.CommandBars("Actions").Enabled = boolVal
End Sub


--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


Bryan Dickerson said:
So can you not set properties of Item.GetInspector if you don't have a
certain authorization?

Bryan Dickerson said:
I'm calling it in Item_Open
SetCmdBars False
... and in Item_Close
SetCmdBars True.

And the users report that it's mostly on the SetCmdBars True call that
they are seeing the errors. I tried setting oF =
Item.GetInspector.ModifiedFormPages.Add("Ticket") (I'm not sure what
that
does exactly, but it works to access the Custom Form User Properties)
but
it only caused more errors.

message Yes, that's the latest version.

At what point are you calling this procedure? On Item_Open? Via a
button?

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


:

I just looked at the public folder whence the custom forms are being
run.
The permissions are correct and there are no exceptions. Outlook
version is
something I've been fighting hard for, but I'm fairly sure that all
these
users are at OL 2003 SP1. That is the latest, right?

in
message Sorry - I didn't realize you were talking about a custom form,
where
of
course the Item object is intrinsic!

I can't imagine why you'd get a permissions error on retrieving the
Inspector object, even if the user only had read permissions -
nothing
is
getting modified, and you can't really alter an item from the
Inspector
object anyway.

You might want to verify the permissions for those users who are
receiving
these errors, and note their Outlook version as well. Otherwise,
I'm
stumped.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


:

Item refers to the Outlook Task Item that is available to the
script
when
it
runs. Since this form runs in a folder where each user has rights
to
create
and alter most anything about the individual tasks, I would have
to
assume
(I know dangerous) that the user could modify the Item object.
But
that
may
be a very faulty assumption. Are there any docs that you could
point
me
to?

"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message Where is the code that declares the Item object?

It obviously sounds like a permissions problem; does the user
have
read
access to the folder that contains the Item you are setting a
reference
to?

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


:

I'm trying to disable a command bar that has occassionally
caused
problems
in a custom form. I came up with this routine:

Sub SetCmdBars(ByVal boolVal)
Dim oF
Dim oCB

Set oF = Item.GetInspector
For Each oCB in oF.CommandBars
If oCB.Name = "Standard" Then
oCB.Enabled = boolVal
oCB.Visible = boolVal
End If
Next
oF.CommandBars("View").Enabled = boolVal
oF.CommandBars("Tools").Enabled = boolVal
oF.CommandBars("Actions").Enabled = boolVal
End Sub

.... and some users are getting the error message:
"You don't have appropriate permission to perform this
operation."
and
the
line number points to the script code line: "Set oF =
Item.GetInspector".

Anyone have any ideas?

Thanx!
 
G

Guest

Well, in hindsight it's pretty obvious, be we had to bat this back and forth
several times until the solution presented itself. Tell your boss it was
your "diligent troubleshooting" that saved the day. :)

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


Bryan Dickerson said:
Thanx. I'll give it a whirl! I can just see the scowl on my boss' face
when I tell him the solution was: "On Error Resume Next"!!

Eric Legault said:
An Inspector object doesn't directly expose the properties of the
underlying
Outlook item, whether Task, Contact, e-mail, etc. It's basically a
wrapper
for the form that displays the content, with properties for window size,
caption, etc. - the "window dressing".

Also, you don't really need to re-enable the commandbars when the item
closes - Outlook resets the commandbars whenever the next item opens - so
you
can get rid of the code in the Item_Close event.

The ModifiedFormPages method is mainly used to retrieve the Controls
collection for a particular page on your custom form. You can always
access
custom fields through the Item.UserProperties collection.

Regardless, just include some error handling to bypass this error anyway:

Sub SetCmdBars(ByVal boolVal)
On Error Resume Next

Dim oF
Dim oCB

Set oF = Item.GetInspector
If Err.Number <> 0 Then Exit Sub 'Problem!
For Each oCB in oF.CommandBars
If oCB.Name = "Standard" Then
oCB.Enabled = boolVal
oCB.Visible = boolVal
End If
Next
oF.CommandBars("View").Enabled = boolVal
oF.CommandBars("Tools").Enabled = boolVal
oF.CommandBars("Actions").Enabled = boolVal
End Sub


--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


Bryan Dickerson said:
So can you not set properties of Item.GetInspector if you don't have a
certain authorization?

I'm calling it in Item_Open
SetCmdBars False
... and in Item_Close
SetCmdBars True.

And the users report that it's mostly on the SetCmdBars True call that
they are seeing the errors. I tried setting oF =
Item.GetInspector.ModifiedFormPages.Add("Ticket") (I'm not sure what
that
does exactly, but it works to access the Custom Form User Properties)
but
it only caused more errors.

message Yes, that's the latest version.

At what point are you calling this procedure? On Item_Open? Via a
button?

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook! http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


:

I just looked at the public folder whence the custom forms are being
run.
The permissions are correct and there are no exceptions. Outlook
version is
something I've been fighting hard for, but I'm fairly sure that all
these
users are at OL 2003 SP1. That is the latest, right?

in
message Sorry - I didn't realize you were talking about a custom form,
where
of
course the Item object is intrinsic!

I can't imagine why you'd get a permissions error on retrieving the
Inspector object, even if the user only had read permissions -
nothing
is
getting modified, and you can't really alter an item from the
Inspector
object anyway.

You might want to verify the permissions for those users who are
receiving
these errors, and note their Outlook version as well. Otherwise,
I'm
stumped.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


:

Item refers to the Outlook Task Item that is available to the
script
when
it
runs. Since this form runs in a folder where each user has rights
to
create
and alter most anything about the individual tasks, I would have
to
assume
(I know dangerous) that the user could modify the Item object.
But
that
may
be a very faulty assumption. Are there any docs that you could
point
me
to?

"Eric Legault [MVP - Outlook]" <[email protected]>
wrote
in
message Where is the code that declares the Item object?

It obviously sounds like a permissions problem; does the user
have
read
access to the folder that contains the Item you are setting a
reference
to?

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
Try Picture Attachments Wizard for Outlook!
http://tinyurl.com/9bby8
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/


:

I'm trying to disable a command bar that has occassionally
caused
problems
in a custom form. I came up with this routine:

Sub SetCmdBars(ByVal boolVal)
Dim oF
Dim oCB

Set oF = Item.GetInspector
For Each oCB in oF.CommandBars
If oCB.Name = "Standard" Then
oCB.Enabled = boolVal
oCB.Visible = boolVal
End If
Next
oF.CommandBars("View").Enabled = boolVal
oF.CommandBars("Tools").Enabled = boolVal
oF.CommandBars("Actions").Enabled = boolVal
End Sub

.... and some users are getting the error message:
"You don't have appropriate permission to perform this
operation."
and
the
line number points to the script code line: "Set oF =
Item.GetInspector".

Anyone have any ideas?

Thanx!
 

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