PDA

View Full Version : Solved: msgbox problems



Slim8589
06-28-2005, 06:53 PM
I continue to struggle with vba excel on my mac.

Among many issues this one is currently taxing me

Dim result As VbMsgBoxResult

seems to throw up an automation not supported error as does any attempt to dim other msgbox attributes.

Do I take it that I can't do it?

the full code, which is fine on a pc, is below.

Any clues?


Dim strMessage, strTitle As String
Dim style As VbMsgBoxStyle
Dim result As VbMsgBoxResult

datecompare = Format(ActiveCell.Value, "d-mmm-yy")

If datecompare = txtDate.Value Then
strMessage = "You have already entered this date once. Do you wish to enter this date again?"
strTitle = "Repeated date message"
style = vbYesNo + vbExclamation + vbDefaultButton2
result = MsgBox(strMessage, style, strTitle)
If result = vbNo Then 'takes you back to menu sheet
Worksheets("Menu").Select
End
End If

xCav8r
06-28-2005, 07:50 PM
I don't have a clue, but I was wondering if you had tried declaring them as variants as a (possibly temporary) workaround?

shades
06-29-2005, 06:00 AM
Howdy, Slim, and welcome to VBAX.

I won't have access to my Mac for another 12 hours (something about work, and all that!), but I'll check for you then, if no one else comes up with a solution.

Killian
06-29-2005, 06:16 AM
Not that I've ever used VBA on a Mac, but I'm assuming some similarity in terms of how the MsgBox function works...

MsgBox returns an Integer, so you'll need:
Dim result As Integer

This returned integer is going to be a known value, so they are assigned as constants within VB - you can use the vbconstant or the integer value, depending on what mood you're in:
vbOK 1
vbCancel 2
vbAbort 3
vbRetry 4
vbIgnore 5
vbYes 6
vbNo 7

Likewise, the messagebox style parameter is a numeric expression. You can use the vbconstants (or their actual values) so for your code to work as is, just declare "result" as an integer as well

Slim8589
06-29-2005, 04:24 PM
Many thanks that got it! Working fine now. Good work folks.

Killian
06-29-2005, 05:25 PM
Cool, happy to help :thumb
I've marked the thread as solved