Vba 从Access设置Word内容控制
我有一个word模板,用于编写文档。我想从MS Access设置word文档中的内容控件。我知道如何在Word中设置项目Vba 从Access设置Word内容控制,vba,ms-access,ms-word,Vba,Ms Access,Ms Word,我有一个word模板,用于编写文档。我想从MS Access设置word文档中的内容控件。我知道如何在Word中设置项目 ActiveDocument.ContentControls(14).Checked = True activedocument.ContentControls(1).DropdownListEntries.Item(3)enter code here 但是,当我试图从Access中执行此操作时,我不知道如何调用内容控件 这是我在替换书签时使用的代码,我曾尝试用它来设置内容
ActiveDocument.ContentControls(14).Checked = True
activedocument.ContentControls(1).DropdownListEntries.Item(3)enter code here
但是,当我试图从Access中执行此操作时,我不知道如何调用内容控件
这是我在替换书签时使用的代码,我曾尝试用它来设置内容控件,但没有成功:
Set WordApp = GetObject(, "Word.Application")
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
WordApp.Documents.Add Template:=strTemplateLocation, NewTemplate:=False
With WordApp.Selection
.GoTo what:=wdGoToBookmark, Name:="COMPANY"
.TypeText [fac]
'that works
Dim oCtrl As ContentControl
set oCtrl = .ContentControl(14)
oCtrl.Checked = True
然后我得到一个编译错误,声明“找不到方法或数据成员”。突出显示倒数第二行的“ContentControl”
我已经很久没有使用代码了,所以如果有明显的问题,请原谅
谢谢,对它进行了一段时间的研究,并找到了修复方法 增加:
dim wDoc as Word.Document
已删除。从With语句中选择
With WordApp
将.Selection添加到书签替换语句中
.Selection.GoTo what:=wdGoToBookmark, Name:="COMPANY"
.Selection.TypeText [fac]
然后对于复选框:
ActiveDocument.ContentControls(6).Checked = True
现在正在工作。对它进行了一段时间的尝试,并找到了修复方法 增加:
dim wDoc as Word.Document
已删除。从With语句中选择
With WordApp
将.Selection添加到书签替换语句中
.Selection.GoTo what:=wdGoToBookmark, Name:="COMPANY"
.Selection.TypeText [fac]
然后对于复选框:
ActiveDocument.ContentControls(6).Checked = True
现在正在工作