Gruppe
Dialog
Bereich
Browser
Thema
UserForm mit Laufschriftfeld
Problem
Es soll eine UserForm mit einem Laufschriftfeld aufgerufen werden. Der Text der Laufschrift ist variabel zu halten.
Lösung
Geben Sie den Ereigniscode in das Klassenmodul der UserForm ein.
ClassModule: frmMarquee
Private Sub cmdContinue_Click()
Unload Me
End Sub
Private Sub cmdText_Click()
Dim sPath As String
WebBrowser1.Navigate ""
sPath = Application.DefaultFilePath & "\marquee.htm"
Call CreateHTML(sPath)
WebBrowser1.Navigate sPath
End Sub
StandardModule: basMain
Sub CallForm()
Dim sFile As String
sFile = Application.DefaultFilePath & "\marquee.htm"
Call CreateHTML(sFile)
With frmMarquee
.WebBrowser1.Navigate url:=sFile
.Show
End With
Kill sFile
End Sub
Sub CreateHTML(sPath As String)
Open sPath For Output As #1
Print #1, "<html>"
Print #1, "<head>"
Print #1, "<style>"
Print #1, "td { "
Print #1, " background-color:#000000;"
Print #1, " color:#ffff00;"
Print #1, " font-family:tahoma,verdana;"
Print #1, " font-size:12px"
Print #1, " }"
Print #1, "</style>"
Print #1, "</head>"
Print #1, "<body bgcolor=#c0c0c0>"
Print #1, "<table border=1 cellpadding=3 cellspacing=1><tr><td width=300>"
Print #1, "<marquee>" & Range("A1").Value & "</marquee>"
Print #1, "</td></tr></table>"
Print #1, "</body>"
Print #1, "</html>"
Close
End Sub