废话不多说还是打开word-视图-工具栏-visual basic,选择Microsoft web浏览器。添加该控件到word页面中。界面设计如下
点击按钮编写如下代码
Sub CommandButton1_Click()
Sub CommandButton1_Click()
On Error GoTo errplay
If TextBox1.Text = "" Then
MsgBox "网址不能为空"
Else
WebBrowser1.Navigate TextBox1.Text
End If
Exit Sub
errplay:
MsgBox "网址不正确"
End Sub
On Error GoTo errplay
If TextBox1.Text = "" Then
MsgBox "网址不能为空"
Else
WebBrowser1.Navigate TextBox1.Text
End If
Exit Sub
errplay:
MsgBox "网址不正确"
End Sub
运行结果如下
下面我们看看如何在word中看电影
首先界面设计如下
点击按钮编写如下代码
Sub CommandButton1_Click()
Sub CommandButton1_Click()
On Error GoTo errplay
If TextBox1.Text = "" Then
MsgBox "路径不能为空"
Else
StormPlayer1.URL = TextBox1.Text
On Error GoTo errplay
If TextBox1.Text = "" Then
MsgBox "路径不能为空"
Else
StormPlayer1.URL = TextBox1.Text
StormPlayer1.play
End If
Exit Sub
errplay:
MsgBox "路径不正确"
End Sub
End If
Exit Sub
errplay:
MsgBox "路径不正确"
End Sub
本文转自 BruceAndLee 51CTO博客,原文链接:http://blog.51cto.com/leelei/308867,如需转载请自行联系原作者