Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / October 2004

Tip: Looking for answers? Try searching our database.

Function problem when I publish

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Curtis Fowler - 30 Sep 2004 15:39 GMT
I used the Function GetMailboxUserName() on page 233, Listing 12.8 from the
book Microsoft Outlook Programming. I added
Sub MailUser()
MsgBox "The Initiator is " & GetMailboxUserName(initiator)
End Sub
& tried it in the VbaProject.OTM module. Seems to work great. When I
copy/paste it into a blank Script Editor on a Task Form & publish it to the
Exchange Server Public Folder, it gives me an error " Expected end of
statement Line number 29."
That line is Dim objApp As Outlook.Application
It gives the same error with Outlook 2002 & 2003. My Inbox is on the
Exchange Serverby default. Any ideas?
Signature

Thanks,
Curtis

Sue Mosher [MVP-Outlook] - 30 Sep 2004 15:57 GMT
That version is for VBA. The version in listing 20.7 is for VBScript. You'll
probably learn a lot by comparing them.

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

>I used the Function GetMailboxUserName() on page 233, Listing 12.8 from the
> book Microsoft Outlook Programming. I added
[quoted text clipped - 9 lines]
> It gives the same error with Outlook 2002 & 2003. My Inbox is on the
> Exchange Serverby default. Any ideas?
Curtis Fowler - 30 Sep 2004 20:45 GMT
Here's what I put in the Script Editor & published it:

Call MailUser
Sub MailUser()
MsgBox "The Initiator is " & GetMailboxUserName(initiator)
End Sub
Function GetMailboxUserName(mailbox)
 Dim objNS
 Dim objInbox
 Dim strName
 Dim intPos
 Set objNS = Application.GetNameSpace("MAPI")
 Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
 strName = objInbox.Parent.Name
 intPos = InStr(1, strName, "Mailbox - ", vbTextCompare)
 If intPos > 0 Then
     GetMailboxUserName = Right(strName, intPos + 9)
 End If
 Set objInbox = Nothing
 Set objNS = Nothing
End Function

When I run it I get a Script Error Line 10 which is  Set objNS = ...
I've looked at every MS reference page & can't find anything wrong with the
structure of any of the code. Sorry but I'm stuck again. Thanks.

> That version is for VBA. The version in listing 20.7 is for VBScript. You'll
> probably learn a lot by comparing them.
[quoted text clipped - 12 lines]
> > It gives the same error with Outlook 2002 & 2003. My Inbox is on the
> > Exchange Serverby default. Any ideas?
Sue Mosher [MVP-Outlook] - 30 Sep 2004 21:23 GMT
I don't know why the Application.GetNamespace statement would fail, but you
can't use olFolderInbox in VBScript unless you have a Const declaration for
it somewhere. Also use Mid instead of Right to get the name:

GetMailboxUserName = Mid(strName, intPos + 9)

Also, I can't see that you're using a proper event handler to call this
code. Put a command button on your form and put your Call MailUser in it:

Sub CommandButton1_Click()
   Call MailUser
End Sub

Click the button to test.

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> Here's what I put in the Script Editor & published it:
>
[quoted text clipped - 26 lines]
>> You'll
>> probably learn a lot by comparing them.

>> >I used the Function GetMailboxUserName() on page 233, Listing 12.8 from
>> >the
[quoted text clipped - 10 lines]
>> > It gives the same error with Outlook 2002 & 2003. My Inbox is on the
>> > Exchange Serverby default. Any ideas?
Curtis Fowler - 30 Sep 2004 21:31 GMT
I tried using the index (6) instead of (olFolderInbox) but still got the error.
I'll try adding a button to see what it does. Thanks.

> I don't know why the Application.GetNamespace statement would fail, but you
> can't use olFolderInbox in VBScript unless you have a Const declaration for
[quoted text clipped - 56 lines]
> >> > It gives the same error with Outlook 2002 & 2003. My Inbox is on the
> >> > Exchange Serverby default. Any ideas?
Curtis Fowler - 01 Oct 2004 15:41 GMT
It likes it working from a Cmd button. No errors at all. Thanks for all your
help Sue!

> I tried using the index (6) instead of (olFolderInbox) but still got the error.
> I'll try adding a button to see what it does. Thanks.
[quoted text clipped - 59 lines]
> > >> > It gives the same error with Outlook 2002 & 2003. My Inbox is on the
> > >> > Exchange Serverby default. Any ideas?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.