如何打开一个word的模板! 最近做一个word的模板程序,打开word是Set NewDoc = MyWord.Documents.Add这是一个新的doc,名字叫文档1(后面会累加,自动的),但是现在我希望直接新建打开一个我写好的模板程序,名字还是叫文档1。请问应该怎么写! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 On Error Resume Next '忽略错误 Set Wrd = GetObject(, "Word.Application") '查找一个正在运行的Word拷贝 If Err.Number <> 0 Then '如果 Word 没有运行则 Set Wrd = CreateObject("Word.Application") '运行它 End If Err.Clear '清除发生错误的 Err 对象 On Error GoTo 0 '保留普通错误进程 Dim dot As String Dim doc As String Wrd.Visible =true dot = "C:\temp.dot" doc = "c:\temp.doc" Documents.Open FileName:=dot, _ ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _ PasswordDocument:="", PasswordTemplate:="", Revert:=False, _ WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _ 0 Wrd.ActiveDocument.Close Wrd.Documents.Add Template:=dot, NewTemplate:=False '结果系列操作 ActiveDocument.SaveAs FileName:=doc, FileFormat:=wdFormatDocument, _ LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _ :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _ False '打印出来 ActiveDocument.PrintOut FileName:=doc, Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 Wrd.ActiveDocument.Close to aiur2000(杀破狼) : 大哥,别一看到:=就以为是Delphi的,这明明就是VB代码嘛。 不好意思,没用过vba,应该去哪看有关这一段代码的,请指点一下。就是vba关于word的应该怎么用。 word工具菜单——》宏——》录制新宏——》为所欲为——》停止录制——》工具菜单——》宏...——》找到你录制的宏——》粘贴宏内代码 Selection.TypeText Text:="您好,先生" 这一句复制过去,报对象变量未设置的错???应该怎么加呢? 引用Word Library并且声明Word对象 求助 !急! 如何添加控件到选项卡控件里 VB6.0 呼唤SSTab控件的高手,怎么添加动态控件? 高手们:在DATAGRID中显示布尔型字段时可否将其显示为“是”、“否”,最好前面再加一个检查框? VB编程中,如何根据已知的数据源名称取得ODBC中对应的数据库名称 关于GIF文件的格式 为什么 "0000003" & "-" & "1" 变成了2 关于mysql的数据备份问题,请帮忙。。。。。 斑竹有奖征集精华贴! 问一个关于WINSOCK的菜鸟级问题。 高分求救,一控件的.datasource 错误,在线等待 一个变量转换成运算符的问题????????
Set Wrd = GetObject(, "Word.Application") '查找一个正在运行的Word拷贝
If Err.Number <> 0 Then '如果 Word 没有运行则
Set Wrd = CreateObject("Word.Application") '运行它
End If
Err.Clear '清除发生错误的 Err 对象
On Error GoTo 0 '保留普通错误进程
Dim dot As String
Dim doc As String
Wrd.Visible =true
dot = "C:\temp.dot"
doc = "c:\temp.doc"
Documents.Open FileName:=dot, _
ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
0
Wrd.ActiveDocument.Close
Wrd.Documents.Add Template:=dot, NewTemplate:=False '结果系列操作
ActiveDocument.SaveAs FileName:=doc, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
'打印出来
ActiveDocument.PrintOut FileName:=doc, Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
Wrd.ActiveDocument.Close
大哥,别一看到:=就以为是Delphi的,这明明就是VB代码嘛。
就是vba关于word的应该怎么用。