View Single Post
 
Old 03-13-2019, 05:43 AM
matapagi2019 matapagi2019 is offline Windows XP Office 2007
Novice
 
Join Date: Mar 2019
Posts: 12
matapagi2019 is on a distinguished road
Default How to prevent the file from opening again on the second click?

When the user clicks "Button1" once, the file "MyAgenda.xlsx" opens.
How do I prevent Excel from opening the file "MyAgenda.xlsx" when the user clicks "Button1" on the second click, third, and so on ?
Because from the following code, the file "MyAgenda" continues to open again and again every time the user clicks on the second one and so on.
Code:
Private Sub Button1_Click()
Dim ObjExcel
Dim ObjXls    
    Set ObjExcel = CreateObject("Excel.Application")
    Set ObjXls = ObjExcel.Workbooks.Open("D:\MyAgenda.xlsx")
    ObjExcel.Visible = True
End Sub
For all assistance, I am very grateful.
Reply With Quote