Open any type of File (doc , ppt, exe...) In Excell VBA User form

Опубликовано: 14 Май 2026
на канале: Excel Vba Automation
72
1

Open any type of File using VBA code.

#,Circular Image control in excel VBA UserForm :-   • Image control(Circular) in excel VBA UserForm  
#,Images/Pictures Locker with excel VBA:-    • Images/Pictures Locker with excel VBA User...  
#, Rotate image/Picture in excel vba userform image control:-   • Rotate image/Picture in excel vba userform...  
Source code:-
#, Auto shutdown, Restart, Logoff, force restart windows:-    • Auto shutdown, Restart, Logoff, Force Rest...  
#, Lock Excel workbook(Login page before access excel sheet) :-    • Lock any Excel Workbook in Excel VBA/Prote...  

.....................................................
Private Sub CommandButton1_Click()

If TextBox1.Text = "" Then
MsgBox "file location is empty", vbCritical
TextBox1.BackColor = vbRed
TextBox2.BackColor = vbWhite
TextBox1.SetFocus
Exit Sub
End If

If TextBox2.Text = "" Then
MsgBox "file Name is empty", vbCritical
TextBox1.BackColor = vbWhite
TextBox2.BackColor = vbRed
TextBox2.SetFocus
Exit Sub
End If

Dim filePathh As String


filePathh = TextBox1.Text & "\" & TextBox2.Text

Dim objShell: Set objShell = CreateObject("shell.application")
objShell.ShellExecute filePathh, "", "", "open", 1
Set objShell = Nothing

End Sub

................................................................
Private Sub CommandButton2_Click()
Application.Visible = True
Unload Me
End Sub
...............................................

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
Application.Quit
End If
End Sub
............................................................

Option Explicit

Private Sub Workbook_Open()
Application.Visible = False
UserForm1.Show
End Sub