PDA

View Full Version : Want to configure inputbox & msgbox in PowerPoint using vba



Jhon90
03-03-2021, 08:23 AM
Sir want a little help.

I want to configure inputbox(only input = 3 will be valid) & msgbox in such a way that if i put number 3 as a input number then it browse my pc's C drive.
Also i want to exit when i hit the X mark in every msgbox/inputbox.

1. When i put nothing/blank in msgbox1(see attachment) & hit ok button then it takes me to msgbox2(see attachment). When i hit the X mark in msgbox2 it takes me to my C drive(in that case i want to exit whenever i hit X mark ).

So I want to configure exactly as shown in attachment picture: wanted_diagram



Dim inputNumber As Long
Dim inputResponse As String
inputResponse = InputBox("Please enter number : ", "Insert Data", "Input only number 3")
If IsNumeric(inputResponse) Then
inputNumber = inputResponse
If inputNumber <> 3 Then
MsgBox "Enter only number 3"
Else: MsgBox "Confirm You want to insert data in " & inputNumber & " blocks"
End If
ElseIf inputResponse = "" Then
MsgBox "You did not enter anything!"
Exit Sub
End If
MsgBox "Please select/browse data excel file from your computer! "
Dim fDialog As FileDialog
Dim filepath As String
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
'Optional: FileDialog properties
fDialog.AllowMultiSelect = False
fDialog.Title = "Select a file"
fDialog.InitialFileName = "C:"
'Optional: Add filters
fDialog.Filters.Clear
fDialog.Filters.Add "Excel files", "*.xlsx"
fDialog.Filters.Add "All files", "*.*"
'Show the dialog. -1 means success!
If fDialog.Show = -1 Then
filepath = fDialog.SelectedItems(1)
Else
End If

SamT
03-06-2021, 12:05 PM
I dunno :dunno:
But play around with

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 'Handles btnExit.Click
Dim x
x = sender.Name
End Sub

John Wilson
03-07-2021, 06:31 AM
This sort of thing maybe

Sub inputter()
Do
Dim strIn As String
strIn = InputBox("Enter 3")
If strIn = "" Then MsgBox "Enter a Number"
If strIn <> "3" And strIn <> "" Then MsgBox "Enter 3"
Loop Until strIn = "3"
' rest of code
End Sub