Splash Screen Questions

mhenk

Well-known Member
Joined
Jun 13, 2005
Messages
591
Hey folks!

I'm adding a userform Splash screen to my project, listing some qualifications & limitations. I can get the form to show up, my 3 questions are:

1) is there a way to load a formatted text file into a control? I'd like to Have this model be totally independant of other files, so if there's a format-able lable or text box that I'm not seeing, that'd be the best bet.

2) how do I enable a button 10 seconds after the form loads?

3) how do I disable (or reprogram) the small "X" at the top corner? ideally, it'd be disabled.

Thanks!
 
This example utilizes the webbrowser control to display your formatted text. As for the RichTextBox control and its availability too you? I don't know... I have so much crap installed on my system that I really don't know which app is came with. As for a developer's license for this control? I doubt that it is available with any installation of Office except for, maybe, the developer's edition. You will have to do your own research on this control.

Example Download: mhenk.302744.xls.zip

Download the example or... to set this up manually, add a worksheet named "Eula", add TextBox1 (ActiveX), and paste in your source HTML into TextBox1. Hide this worksheet.

Add a userform named "qual_limit" containing WebBrowser1, a commandbutton named "Accept", a commandbutton named "Decline".

Paste this code into your userform:
<table width="100%" border="1" bgcolor="White" style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"><tr><TD><font size="2" face=Courier New>  <font color="#0000A0">Option</font> <font color="#0000A0">Explicit</font>

  <font color="#0000A0">Private</font> pAccepted <font color="#0000A0">As</font> <font color="#0000A0">Boolean</font>

  <font color="#0000A0">Friend</font> <font color="#0000A0">Property</font> <font color="#0000A0">Get</font> Accepted() <font color="#0000A0">As</font> <font color="#0000A0">Boolean</font>
       Accepted = pAccepted
  <font color="#0000A0">End</font> <font color="#0000A0">Property</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> Accept_Click()
      <font color="#008000"> 'user clicks "Accept", lets them into the model</font>
       pAccepted = <font color="#0000A0">True</font>
       Me.Hide
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> Decline_Click()
       Me.Hide
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Public</font> <font color="#0000A0">Sub</font> UserForm_Activate()
       qual_limit.Caption = ActiveWorkbook.FullName
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Friend</font> <font color="#0000A0">Sub</font> EnableButton()
       Accept.Enabled = <font color="#0000A0">True</font>
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> UserForm_QueryClose(Cancel <font color="#0000A0">As</font> Integer, CloseMode <font color="#0000A0">As</font> Integer)
      <font color="#008000"> 'Disables the "X" button</font>
       <font color="#0000A0">If</font> CloseMode = vbFormControlMenu <font color="#0000A0">Then</font>
           MsgBox "Please Accept or Decline the Qualifications & Limitations"
           Cancel = <font color="#0000A0">True</font>
       <font color="#0000A0">End</font> <font color="#0000A0">If</font>
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>
</FONT></td></tr></table><button onclick='document.all("1126200715823300").value=document.all("1126200715823300").value.replace(/<br \/>\s\s/g,"");document.all("1126200715823300").value=document.all("1126200715823300").value.replace(/<br \/>/g,"");window.clipboardData.setData("Text",document.all("1126200715823300").value);'>Copy to Clipboard</BUTTON><textarea style="position:absolute;visibility:hidden" name="1126200715823300" wrap="virtual">
Option Explicit

Private pAccepted As Boolean

Friend Property Get Accepted() As Boolean
Accepted = pAccepted
End Property

Private Sub Accept_Click()
'user clicks "Accept", lets them into the model
pAccepted = True
Me.Hide
End Sub

Private Sub Decline_Click()
Me.Hide
End Sub

Public Sub UserForm_Activate()
qual_limit.Caption = ActiveWorkbook.FullName
End Sub

Friend Sub EnableButton()
Accept.Enabled = True
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Disables the "X" button
If CloseMode = vbFormControlMenu Then
MsgBox "Please Accept or Decline the Qualifications & Limitations"
Cancel = True
End If
End Sub</textarea>

Paste this into your workbook class:
<table width="100%" border="1" bgcolor="White" style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"><tr><TD><font size="2" face=Courier New>  <font color="#0000A0">Option</font> <font color="#0000A0">Explicit</font>

  <font color="#0000A0">Dim</font> ql <font color="#0000A0">As</font> qual_limit, AgreementAccepted <font color="#0000A0">As</font> <font color="#0000A0">Boolean</font>
  <font color="#0000A0">Private</font> <font color="#0000A0">Const</font> DelaySeconds <font color="#0000A0">As</font> <font color="#0000A0">Integer</font> = 5
  <font color="#0000A0">Private</font> DelaySecondsCnt <font color="#0000A0">As</font> <font color="#0000A0">Integer</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> Workbook_BeforeClose(Cancel <font color="#0000A0">As</font> Boolean)
       <font color="#0000A0">If</font> AgreementAccepted <font color="#0000A0">Then</font>
          <font color="#008000"> 'run code if Agreement accepted...</font>

       <font color="#0000A0">Else</font>
          <font color="#008000"> 'don't run code if Agreement declined...</font>

       <font color="#0000A0">End</font> <font color="#0000A0">If</font>

  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> Workbook_Open()
       SetUpEulaForm
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> SetUpEulaForm()
       <font color="#0000A0">Dim</font> TempEulaPath <font color="#0000A0">As</font> <font color="#0000A0">String</font>

       TempEulaPath = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "tempEula.htm")

       <font color="#0000A0">Open</font> TempEulaPath <font color="#0000A0">For</font> <font color="#0000A0">Output</font> <font color="#0000A0">As</font> #1
       <font color="#0000A0">Print</font> #1, Sheets("Eula").TextBox1.Text
       <font color="#0000A0">Close</font> #1

       <font color="#0000A0">Set</font> ql = <font color="#0000A0">New</font> qual_limit
       ql.WebBrowser1.Navigate TempEulaPath
       Application.OnTime Now + TimeSerial(0, 0, 1), ThisWorkbook.CodeName & ".UpdateButton"
       ql.Show vbModal
       AgreementAccepted = ql.Accepted

       <font color="#0000A0">If</font> AgreementAccepted <font color="#0000A0">Then</font>
           MsgBox "Agreement accepted..."
       <font color="#0000A0">Else</font>
           MsgBox "Agreement declined..."
           MsgBox "ThisWorkbook.Close False"
       <font color="#0000A0">End</font> <font color="#0000A0">If</font>

       <font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">Resume</font> <font color="#0000A0">Next</font>
       Unload ql
       <font color="#0000A0">Set</font> ql = <font color="#0000A0">Nothing</font>
       Kill TempEulaPath
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> UpdateButton()
       <font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">Resume</font> <font color="#0000A0">Next</font>
       DelaySecondsCnt = DelaySecondsCnt + 1
       <font color="#0000A0">If</font> DelaySecondsCnt >= DelaySeconds <font color="#0000A0">Then</font>
           ql.Accept.Caption = "Accept"
           ql.Accept.Enabled = <font color="#0000A0">True</font>
       <font color="#0000A0">Else</font>
           ql.Accept.Caption = "(" & Abs(DelaySecondsCnt - DelaySeconds) & ") Accept"
           Application.OnTime Now + TimeSerial(0, 0, 1), ThisWorkbook.CodeName & ".UpdateButton"
       <font color="#0000A0">End</font> <font color="#0000A0">If</font>
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

</FONT></td></tr></table><button onclick='document.all("11262007151257466").value=document.all("11262007151257466").value.replace(/<br \/>\s\s/g,"");document.all("11262007151257466").value=document.all("11262007151257466").value.replace(/<br \/>/g,"");window.clipboardData.setData("Text",document.all("11262007151257466").value);'>Copy to Clipboard</BUTTON><textarea style="position:absolute;visibility:hidden" name="11262007151257466" wrap="virtual">
Option Explicit

Dim ql As qual_limit, AgreementAccepted As Boolean
Private Const DelaySeconds As Integer = 5
Private DelaySecondsCnt As Integer

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If AgreementAccepted Then
'run code if Agreement accepted...

Else
'don't run code if Agreement declined...

End If

End Sub

Private Sub Workbook_Open()
SetUpEulaForm
End Sub

Private Sub SetUpEulaForm()
Dim TempEulaPath As String

TempEulaPath = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "tempEula.htm")

Open TempEulaPath For Output As #1
Print #1, Sheets("Eula").TextBox1.Text
Close #1

Set ql = New qual_limit
ql.WebBrowser1.Navigate TempEulaPath
Application.OnTime Now + TimeSerial(0, 0, 1), ThisWorkbook.CodeName & ".UpdateButton"
ql.Show vbModal
AgreementAccepted = ql.Accepted

If AgreementAccepted Then
MsgBox "Agreement accepted..."
Else
MsgBox "Agreement declined..."
MsgBox "ThisWorkbook.Close False"
End If

On Error Resume Next
Unload ql
Set ql = Nothing
Kill TempEulaPath
End Sub

Private Sub UpdateButton()
On Error Resume Next
DelaySecondsCnt = DelaySecondsCnt + 1
If DelaySecondsCnt >= DelaySeconds Then
ql.Accept.Caption = "Accept"
ql.Accept.Enabled = True
Else
ql.Accept.Caption = "(" & Abs(DelaySecondsCnt - DelaySeconds) & ") Accept"
Application.OnTime Now + TimeSerial(0, 0, 1), ThisWorkbook.CodeName & ".UpdateButton"
End If
End Sub
</textarea>
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Bottom of agreement states:

"If this product was acquired outside of the United States, local lay may apply."

Shame on them... :)
 
Upvote 0
Alright, that's working pretty well, the web browser thing is pretty sweet One quick tweak I haven't been able to figure out.

When the user clicks "Decline" before the "Accept" Button is enabled, Excel reopens the file. How do I work around that?
 
Upvote 0
<table width="100%" border="1" bgcolor="White" style="filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"><tr><TD><font size="2" face=Courier New>  <font color="#0000A0">Option</font> <font color="#0000A0">Explicit</font>

  <font color="#0000A0">Dim</font> ql <font color="#0000A0">As</font> qual_limit, AgreementAccepted <font color="#0000A0">As</font> <font color="#0000A0">Boolean</font>
  <font color="#0000A0">Private</font> <font color="#0000A0">Const</font> DelaySeconds <font color="#0000A0">As</font> <font color="#0000A0">Integer</font> = 5
  <font color="#0000A0">Private</font> DelaySecondsCnt <font color="#0000A0">As</font> <font color="#0000A0">Integer</font>
  <font color="#0000A0">Private</font> RunNextOnTime <font color="#0000A0">As</font> <font color="#0000A0">Date</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> Workbook_BeforeClose(Cancel <font color="#0000A0">As</font> Boolean)
       <font color="#0000A0">If</font> AgreementAccepted <font color="#0000A0">Then</font>
          <font color="#008000"> 'run code if Agreement accepted...</font>

       <font color="#0000A0">Else</font>
          <font color="#008000"> 'don't run code if Agreement declined...</font>

       <font color="#0000A0">End</font> <font color="#0000A0">If</font>

  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> Workbook_Open()
       SetUpEulaForm
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> SetUpEulaForm()
       <font color="#0000A0">Dim</font> TempEulaPath <font color="#0000A0">As</font> <font color="#0000A0">String</font>

       TempEulaPath = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "tempEula.htm")

       <font color="#0000A0">Open</font> TempEulaPath <font color="#0000A0">For</font> <font color="#0000A0">Output</font> <font color="#0000A0">As</font> #1
       <font color="#0000A0">Print</font> #1, Sheets("Eula").TextBox1.Text
       <font color="#0000A0">Close</font> #1

       <font color="#0000A0">Set</font> ql = <font color="#0000A0">New</font> qual_limit
       ql.WebBrowser1.Navigate TempEulaPath
       RunNextOnTime = Now + TimeSerial(0, 0, 1)
       Application.OnTime RunNextOnTime, ThisWorkbook.CodeName & ".UpdateButton"
       ql.Show vbModal
       AgreementAccepted = ql.Accepted

       <font color="#0000A0">If</font> AgreementAccepted <font color="#0000A0">Then</font>
          <font color="#008000"> 'MsgBox "Agreement accepted..."</font>
       <font color="#0000A0">Else</font>
          <font color="#008000"> 'MsgBox "Agreement declined..."</font>
           <font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">Resume</font> <font color="#0000A0">Next</font>
           Application.OnTime RunNextOnTime, ThisWorkbook.CodeName & ".UpdateButton", , <font color="#0000A0">False</font>
           Unload ql
           <font color="#0000A0">Set</font> ql = <font color="#0000A0">Nothing</font>
           Kill TempEulaPath
           Me.Close <font color="#0000A0">False</font>
       <font color="#0000A0">End</font> <font color="#0000A0">If</font>

       <font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">Resume</font> <font color="#0000A0">Next</font>
       Unload ql
       <font color="#0000A0">Set</font> ql = <font color="#0000A0">Nothing</font>
       Kill TempEulaPath
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

  <font color="#0000A0">Private</font> <font color="#0000A0">Sub</font> UpdateButton()
       <font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">Resume</font> <font color="#0000A0">Next</font>
       DelaySecondsCnt = DelaySecondsCnt + 1
       <font color="#0000A0">If</font> DelaySecondsCnt >= DelaySeconds <font color="#0000A0">Then</font>
           ql.Accept.Caption = "Accept"
           ql.Accept.Enabled = <font color="#0000A0">True</font>
       <font color="#0000A0">Else</font>
           ql.Accept.Caption = "(" & Abs(DelaySecondsCnt - DelaySeconds) & ") Accept"
           RunNextOnTime = Now + TimeSerial(0, 0, 1)
           Application.OnTime RunNextOnTime, ThisWorkbook.CodeName & ".UpdateButton"
       <font color="#0000A0">End</font> <font color="#0000A0">If</font>
  <font color="#0000A0">End</font> <font color="#0000A0">Sub</font>

</FONT></td></tr></table><button onclick='document.all("1128200742333858").value=document.all("1128200742333858").value.replace(/<br \/>\s\s/g,"");document.all("1128200742333858").value=document.all("1128200742333858").value.replace(/<br \/>/g,"");window.clipboardData.setData("Text",document.all("1128200742333858").value);'>Copy to Clipboard</BUTTON><textarea style="position:absolute;visibility:hidden" name="1128200742333858" wrap="virtual">
Option Explicit

Dim ql As qual_limit, AgreementAccepted As Boolean
Private Const DelaySeconds As Integer = 5
Private DelaySecondsCnt As Integer
Private RunNextOnTime As Date

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If AgreementAccepted Then
'run code if Agreement accepted...

Else
'don't run code if Agreement declined...

End If

End Sub

Private Sub Workbook_Open()
SetUpEulaForm
End Sub

Private Sub SetUpEulaForm()
Dim TempEulaPath As String

TempEulaPath = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "tempEula.htm")

Open TempEulaPath For Output As #1
Print #1, Sheets("Eula").TextBox1.Text
Close #1

Set ql = New qual_limit
ql.WebBrowser1.Navigate TempEulaPath
RunNextOnTime = Now + TimeSerial(0, 0, 1)
Application.OnTime RunNextOnTime, ThisWorkbook.CodeName & ".UpdateButton"
ql.Show vbModal
AgreementAccepted = ql.Accepted

If AgreementAccepted Then
'MsgBox "Agreement accepted..."
Else
'MsgBox "Agreement declined..."
On Error Resume Next
Application.OnTime RunNextOnTime, ThisWorkbook.CodeName & ".UpdateButton", , False
Unload ql
Set ql = Nothing
Kill TempEulaPath
Me.Close False
End If

On Error Resume Next
Unload ql
Set ql = Nothing
Kill TempEulaPath
End Sub

Private Sub UpdateButton()
On Error Resume Next
DelaySecondsCnt = DelaySecondsCnt + 1
If DelaySecondsCnt >= DelaySeconds Then
ql.Accept.Caption = "Accept"
ql.Accept.Enabled = True
Else
ql.Accept.Caption = "(" & Abs(DelaySecondsCnt - DelaySeconds) & ") Accept"
RunNextOnTime = Now + TimeSerial(0, 0, 1)
Application.OnTime RunNextOnTime, ThisWorkbook.CodeName & ".UpdateButton"
End If
End Sub
</textarea>
 
Upvote 0
is there something I can put in a BeforeSave routine that will prevent the file from saving?
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,392
Members
449,445
Latest member
JJFabEngineering

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