Sue:
Thanks again. I was looking at the article in MSDN explaining the
differences between VBScript and VBA when I noticed what you just said. We
were always taught never to use GoTo. I also changed your logic a bit to
remove the NOTs. Here is what I have now, but the syntax error is still in
the same place. I am counting comment lines in my HTML file to see if I can
figure out where it is telling me the error may be. I'm stumped.
Function SetAccount(AccountName, MItem)
Dim OLI 'As Outlook.Inspector
Dim strAccountBtnName 'As String
Dim intLoc 'As Integer
Const ID_ACCOUNTS = 31224
Dim CBs 'As Office.CommandBars
Dim CBP 'As Office.CommandBarPopup
Dim MC 'As Office.CommandBarControl
Set OLI = MItem.GetInspector
Set CBs = OLI.CommandBars
Set CBP = CBs.FindControl(, 31224)
If CBP Is Nothing Then
Set_Account = ""
Else
For Each MC In CBP.Controls
intLoc = InStr(MC.Caption, " ")
If intLoc > 0 Then
strAccountBtnName = Mid(MC.Caption, intLoc + 1)
Else
strAccountBtnName = MC.Caption
End If
If strAccountBtnName = AccountName Then
MC.Execute
Set_Account = AccountName
End If
Next
End If
'Clean up
Set MC = Nothing
Set CBP = Nothing
Set CBs = Nothing
Set OLI = Nothing
End Function
"Sue Mosher [MVP-Outlook]" <(E-Mail Removed)> wrote in message
news:eE%(E-Mail Removed)...
Try taking out the Exit_Function: statement and replacing GoTo Exit_Function
with Exit For. VBScript doesn't support that kind of branching.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Mark Milliman" <(E-Mail Removed)> wrote in message
news:Od$(E-Mail Removed)...
>I need to convert a function borrowed from Sue to VBScript but I am far
>from
> a VB expert. I know that it should be a simple job, but FrontPage says
> that
> there is a syntax error. The problem is that the line numbers do not
> match
> where the error is located. The VB function runs fine in the VBE but not
> in
> a web page in Outlook.
>
> The subroutine that calls the function works well without the function so
> I
> know that the problem has to lie in the function. Here is my hacked
> version
> of the code.
>
> Function Set_Account(AccountName, M)
> Dim OLI 'As Outlook.Inspector
> Dim strAccountBtnName 'As String
> Dim intLoc 'As Integer
> ' Const ID_ACCOUNTS = 31224
>
> Dim CBs 'As Office.CommandBars
> Dim CBP 'As Office.CommandBarPopup
> Dim MC 'As Office.CommandBarControl
>
> Set OLI = M.GetInspector
> If Not OLI Is Nothing Then
> Set CBs = OLI.CommandBars
> Set CBP = CBs.FindControl(, 31224)
> If Not CBP Is Nothing Then
> For Each MC In CBP.Controls
> intLoc = InStr(MC.Caption, " ")
> If intLoc > 0 Then
> strAccountBtnName = Mid(MC.Caption, intLoc + 1)
> Else
> strAccountBtnName = MC.Caption
> End If
> If strAccountBtnName = AccountName Then
> MC.Execute
> Set_Account = AccountName
> GoTo Exit_Function
> End If
> Next
> End If
> End If
> Set_Account = ""
>
> Exit_Function:
> Set MC = Nothing
> Set CBP = Nothing
> Set CBs = Nothing
> Set OLI = Nothing
> End Function