我正在使用Access将数据发送到我在Word中创建的模板。在它成功发送我需要使打开的Word文档不可编辑的数据之后。Word自动化:不可编辑
另外,我注意到在完成文档后,它会提示保存。是否可以删除此提示,但允许保存功能。
这是我用来做字自动化代码:
' Create a Word document from template.
Dim WordApp As Word.Application
Dim strTemplateLocation As String
Dim myVariable As String
myVariable = “TEST!!”
' Specify location of template
strTemplateLocation = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\")) & "test.dot"
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
WordApp.Documents.Add Template:=strTemplateLocation, NewTemplate:=False
' Replace each bookmark with field contents.
WordApp.Selection.GoTo what:=wdGoToBookmark, Name:="myBookmark"
WordApp.Selection.TypeText myVariable
DoEvents
WordApp.Activate
Set WordApp = Nothing
如果您显示实际的代码,提出建议会容易得多。否则,我们都必须猜测你目前是如何做到的。 –
这是否甚至编译?看着Dim myVariable =“TEST !!”... –
这是一个例子。固定。 – Rick