Code help needed

S

soundneedle

(newbie)
While viewing the calendar, a user clicks on an appointment which opens
my form. I'd like to code which form's page shows. Here's my vbscript:

sub Item_Open()
Set myolapp=createobject("Outlook.application")
Set myInspector = createobject("Outlook.Inspector")
Set myInspector = myOlApp.ActiveInspector
myInspector.ShowFormPage ("Page2")
end sub

I know this thing is probably riddled with problems. I understand VBA,
but this vbscript is another story...

Anyone have any suggestions to what I'm doing wrong here??
 
S

soundneedle

I feel ridiculous. I figured it out:

sub Item_Open()
if [categories]="People" then
Item.GetInspector.ShowFormPage("People")
item.getinspector.hideformpage("Companies")
else
Item.GetInspector.ShowFormPage("Companies")
item.getinspector.hideformpage("People")
end if
end sub
 
S

Sue Mosher [MVP-Outlook]

Outlook form VBScript supports an intrinsic Application object and an intrinsic Item object. Also, Item_Open is a function:

Function Item_Open
Set myInspector = Item.GetInspector
myInspector.ShowFormPage "Page2"
Set myInspector = Nothing
End Function
 
S

soundneedle

Sue, is it better practice to use your method than the one I pieced
together? Also, I publish this form to a shared calendar/folder, but
the code will not execute after publishing.

I checked out http://www.outlookcode.com/d/formpub.htm and still can't
figure out why it's not executing. (If I open the form and then design,
run...it executes).

Thanks for any suggestions!
 
S

Sue Mosher [MVP-Outlook]

I don't know what your method is, since you didn't quote your earlier message.

What do you mean by "shared calendar"? In a public folder? In a mailbox? Outlook version?
 
S

soundneedle

I'm not sure of the correct term, but probably a public folder. I go to
file, open, other user's folder (calendar type). I'm using OL2003.
 
S

Sue Mosher [MVP-Outlook]

No, that's not a public folder. A public folder is a folder in the Public Folders hierarchy. What you're describing is a mailbox folder. Form code won't run there by default; see http://www.outlookcode.com/d/ol2003problems.htm for information on the registry change that will make it work.

Also note: The newsgroup interface you are using apparently does not quote earlier messages in the thread, making your latest message so short on detail that you risk not getting the answer you're looking for. Please take the time to quote the original message.
 
S

soundneedle

Thanks for your help, Sue. I toggled the option and it works. The only
problem with this method is I have to get anyone who's using my shared
calendar to do the same, or learn a different way of doing this.

Thanks again...

No, that's not a public folder. A public folder is a folder in the
Public Folders hierarchy. What you're describing is a mailbox folder.
Form code won't run there by default; see
http://www.outlookcode.com/d/ol2003problems.htm for information on the
registry change that will make it work.
Also note: The newsgroup interface you are using apparently does not
quote earlier messages in the thread, making your latest message so
short on detail that you risk not getting the answer you're looking
for. Please take the time to quote the original message.
 
S

Sue Mosher [MVP-Outlook]

Group policy objects are your friend. (Or a handy .reg file)

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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