咔片PPT · AI自动生成演示文稿,模板丰富、排版精美 讯飞智文 · 一键生成PPT和Word,高效应对学习与办公

内容导航:


一、如何用vb调用word打开网页


例如单击Command1,调用word打开网页D:index.html
Private Sub Command1_Click()
Set WSH = CreateObject("WScript.Shell")
path = WSH.RegRead("HKLMSOFTWAREMicrosoftWindowsCurrentVersionApp PathsWinword.exe")
Shell path & " ""D:index.html"""
End Sub

Private Sub Command1_Click()
Set WSH = CreateObject("WScript.Shell")
doc = WSH.RegRead("HKCR.doc")
path = WSH.RegRead("HKCR" & doc & "shellOpencommand")
i = InStr(path, "/")
If i <> 0 Then path = Left(path, i - 1)
Shell path & " ""D:index.html"""
End Sub


二、用vb如何读取光盘上的word文档


在Command1_click下加入一行:
shell "Word的路径winword.exe" 光盘里word文件的路径
假如word在C:Program FilesMicrosoft officeOFFICE11,光盘里word文档的路径为G:abc.doc则添加这样一行即可:
Private sub Command1_Click()
shell "C:Program FilesMicrosoft OfficeOFFICE11winword.exe" G:abc.doc
End sub


三、问vb如何操作word的问题


Set wd=CreateObject("word.application") '创建一个word程序
wd.Visible=True '让word程序可见
Set doc=wd.Documents.Open "你的文件名全路径" '打开一个指定文件
doc.PrintPreview=True '打印预览
doc.PrintOut Background:=False,ManualDuplexPrint:=True '使用双面方式打印
wd.Quit 0 '不保存退出
Set wd =Nothing
Set doc=Nothing

顺便送上word api手册供参考