I need to pause my macro to allow the user to select a text string from a pre-existing listbox named “Macrotext”, then assign the chosen string to a variable “oField2”, and resume the macro. I’m not quite sure how to go about this. I’ve explored the msgbox and Input Box functions, but I don’t see a way to allow the user to select from a listbox instead of the buttons on a msgbox or text from an input Box. Below is the code I’m working with. The area in the code marked “NOT SURE WHAT TO DO HERE” is the area of interest. Here I started to use a msgbox to pause the macro, and assign the result of the msgbox function to a variable for use in an IF THEN statement, but didn’t know where to go from there.
Thanks in advance for any input.
REM ***** BASIC *****
Sub ShowText(answer)
Dim oForm As Object
Dim oSubForm As Object
Dim oSubForm2 As Object
Dim oField As Object
Dim oField2 As Object
Dim string1 As String
Dim string2 AS String
Dim string3 As String
Dim Occur AS String
Dim Return_value As String
'Get the forms
oForm = ThisComponent.Drawpage.Forms.getByName("Patient Data") 'Get Form
oSubForm = oForm.getByName("Chief Complaint") 'Get Subform
oSubForm2 = oSubForm.getByName("Diagnoses") 'Get Subform2
'Get fields
'Get "A_P" textbox where SOAP note contents will be displayed and "Macrotext" listbox
oField = oSubForm.getByName("A_P")
oSubForm2.getByName("Macrotext")
'Need to pause here to get user input from "Macrotext" list box selection
Return_value = MsgBox("Please choose macro text from dropdown list", OKOnly,)
If Return_value = "1" then <NOT SURE WHAT TO DO HERE> 'user pushed "OK" button
'Get listbox "Macrotext" contents to replace "LOCATION" via SelectedValue function below
oField2 = oSubForm2.getByName("Macrotext")
' Insert text to display in "A_P" textbox
oField.text = oField.text + Answer
'Search contents of "A_P" textbox after insertion for occurance of "LOCATION" and replace with selection from "Macrotext" listbox
string1 = oField.text 'string to be searched in Replace procedure
string2 = "LOCATION" 'string to be searched for in Replace procedure
string3 = oField2.SelectedValue 'Get "Macrotext" listbox selection for replacement string
Occur = Replace(string1, string2,string3)
oField.text = Occur
End Sub