Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help please

Status
Not open for further replies.

Tmole99

IS-IT--Management
Jan 16, 2004
12
GB
The following is a bit of VB Script which is supposed to extract the password from an Outlook form.

When I run it as a Macro under Outlook I get the following error message: ARGUMENT NOT OPTIONAL

I'm no programmer so any help would be nice :)






GetFormPassword()

Dim objApp As Application

Dim objInsp As Inspector

Dim objFD As FormDescription

Set objApp = CreateObject("Outlook.Application")

Set objInsp = objApp.ActiveInspector

If Not objInsp Is Nothing Then

Set objFD = objInsp.CurrentItem.FormDescription

MsgBox _

Prompt:="The password for the " & _

Chr(34) & objFD.MessageClass & _

Chr(34) & " form is:" & _

vbCrLf & vbCrLf & objFD.Password, _

Title:="Get Form Password"

Else

MsgBox _

Prompt:="Please open an item using " & _

"the desired form before you " & _

"run the GetFormPassword macro.", _

Title:="Get Form Password"

End If

Set objFD = Nothing

Set objNS = Nothing

Set objApp = Nothing

End Sub
 
Which line does the error occur on? Your code looked OK to me so I just tested it in a OL2002 macro and it worked fine. I changed the object declarations, Set objNS = Nothing (you don't use a namespace object) and removed the blank lines but none of that would have fixed the error you got:
Code:
Sub Test()

    Dim objApp As Outlook.Application
    Dim objInsp As Outlook.Inspector
    Dim objFD As Outlook.FormDescription

    Set objApp = CreateObject("Outlook.Application")
    Set objInsp = objApp.ActiveInspector
    If Not objInsp Is Nothing Then
        Set objFD = objInsp.CurrentItem.FormDescription
        MsgBox _
        Prompt:="The password for the " & _
        Chr(34) & objFD.MessageClass & _
        Chr(34) & " form is:" & _
        vbCrLf & vbCrLf & objFD.Password, _
        Title:="Get Form Password"
    Else
        MsgBox _
        Prompt:="Please open an item using " & _
        "the desired form before you " & _
        "run the GetFormPassword macro.", _
        Title:="Get Form Password"
    End If

    Set objFD = Nothing
    Set objInsp = Nothing
    Set objApp = Nothing
    
End Sub
[/code}

Paul Bent
Northwind IT Systems
[URL unfurl="true"]http://www.northwindit.co.uk[/URL]
 
Thanks

I cut and pasted your new code and it worked a treat.

Thansk again, its saved me hours of work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top