Adding Message Box to Macro

J

Jason Lopez

I have some code where it is counting the number of instances in an
automated search for an array of items. At the end of the search, I am
wanting a box to be displayed that indicates the counts the number of items
in the array that were found. When the item is found, it is highlighted in
the document. Then, the reviewer is to go back and find those highlighted
items in order to add that metadata to a seperate database.

I found the following code on the MSDN website. But, it does not seem to
want to work.

Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Do you want to continue?" ' Define message.
style = MsgBoxStyle.DefaultButton2 Or _
MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
title = "MsgBox Demonstration" ' Define title.
' Display message.
response = MsgBox(msg, style, title)
If response = MsgBoxResult.Yes Then ' User chose Yes.
' Perform some action.
Else
' Perform some other action.
End If

I have modified the code to the following in order to have it do what I
want:

Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "You have " & SearchCount & " occurrences of your search to review."
' Define message.
style = MsgBoxStyle.DefaultButton1 Or _
MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly Or
MsgBoxStyle.ApplicationModal
title = "Enter Information Into RMO Database" ' Define title.
' Display message.
response = MsgBox(msg, style, title)

When I try and run the macro, I get a critical error box that states
"Compile error: User-defined type not defined." The highlighted section for
the error points to the line that says "Dim style As MsgBoxStyle."

I am not sure what else to do as all the rest of the coding for the searches
work as they should. But I can't get the SearchCount variable to display in
order to verify that part. Can anyone point out anything that I might be
doing wrong on this code?

Jason Lopez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top