Coding error with splash screen on open

excel_321

New Member
Joined
Jul 14, 2014
Messages
36
Hi all,

I am using this code to open a workbook with a splash screen as follows. Unfortunately when I enter it and try to exit, I get an error which states:

"Compile error:
Ambiguous name detected: Workbook_BeforeClose"

What should i do to correct it?

Code:
Private Sub Workbook_Open()
    MSG1 = MsgBox("Spreadsheet created by ABC." & Chr(10) & Chr(10) & _"2019." & Chr(10) & Chr(10) & _    
"By selecting Yes to this message box you agree to the following Terms of Use:" & Chr(10) & _    
"No part of this product may be shared with third parties." & Chr(10) & _    Chr(10) & 
"The information held within is accurate as of Jan 2019." & Chr(10) & Chr(10) & _    
"Contact Us: xx@xx.com", vbYesNo, "Terms of Use")        

If MSG1 = vbYes Then  ActiveSheet.Range("A1").Select
Else  MsgBox "This Workbook Will Now Close"  
ActiveWorkbook.Close SaveChanges = False
End If        

    With Application
        .ShowChartTipNames = False
        .ShowChartTipValues = False
    End With
    AppEventsOn
    Worksheets(1).Activate
    ActivateSheet ActiveSheet

        Dim exdate As Date
    exdate = "12/12/2020"
    If Date > exdate Then
        MsgBox ("You have reached end of your time")
        ActiveWorkbook.Close
    End If
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    With Application
        .ShowChartTipNames = True
        .ShowChartTipValues = True
    End With
    AppEventsOff
End Sub

    
--------------------------------------------------------------------

Private Sub Workbook_BeforeClose(Cancel As Boolean)' 
--------------------------------------------------------------------    
With Application
        .ShowChartTipNames = True
        .ShowChartTipValues = True
    End With    AppEventsOff
End Sub
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Delete one of the BeforeClose events
 
Upvote 0
Delete one of the BeforeClose events

How do I do this. I'm not strong on VBA. The above code I took from another spreadsheet in which it worked like a treat. Essentially what I want this code to be able to do is to open the file with a splash screen seeking a YES/No to terms of conditions before using the file. It also has a trial period date set after which the file automatically closes.

Please advise
 
Upvote 0
Simply select this
Code:
--------------------------------------------------------------------

Private Sub Workbook_BeforeClose(Cancel As Boolean)' 
--------------------------------------------------------------------    
With Application
        .ShowChartTipNames = True
        .ShowChartTipValues = True
    End With    AppEventsOff
End Sub
& press delete
 
Upvote 0

Forum statistics

Threads
1,215,499
Messages
6,125,163
Members
449,210
Latest member
grifaz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top