-1

I'm getting the error message "Compile Error: Named argument not found," when I try to run my VBA code. VBA doesn't seem to recognize the last property VbMsgBoxStyle.

Dim dump As VbMsgBoxResult
dump = VBA.Interaction.MsgBox _
       Title:="Invalid Scope!", _
       Prompt:="You entered Invalid Scope !!!", _
       VbMsgBoxStyle:=vbCritical

On the other hand my Object Browser shows this for MsgBox:

Function MsgBox(Prompt, [Buttons As VbMsgBoxStyle = vbOKOnly], [Title], [HelpFile], [Context]) As VbMsgBoxResult
    Member of VBA.Interaction

Does anyone have an idea why this is happening?

3

The property is Buttons not vbMsgBoxStyle. Your code should read like this:

VBA.Interaction.MsgBox _
            Title:="Invalid Scope!", _
            Prompt:="You entered Invalid Scope !!!", _
            Buttons:=vbCritical
1
  • Now I feel dumb. The answer was even on my screen Thanks – sgp667 Nov 3 '14 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.