【发布时间】:2019-06-19 20:12:38
【问题描述】:
目前我有一个 Word 文档,它是一份问卷。
格式(共 30 题):
姓名:
1. Question
YES checkbox
NO checkbox
Comments
2. Question
YES checkbox
NO checkbox
Comments
复选框和 cmets 是控件。
我要做的是将复选框和注释数据提取到excel中。例如,
1. Do you spend time under the sun?
YES checkbox is selected
Comments: I spend 2 days out of the week in the sun.
我希望它在 excel 中显示的是什么。
每次运行宏时,都应在现有记录(行)下方添加新信息。
我通常使用Word,将excel中的数据提取到word中,但我从未尝试过。
这是我目前想出的:
Sub Macro1()
Application.ScreenUpdating = False
Dim lRow As Long, i As Long, j As Long, iCtr As Long, cBox As CheckBox, StrFlNm As String
With Application.FileDialog(FileDialogType:=msoFileDialogFilePicker)
SendKeys "%n *.doc ~"
If .Show = True Then
StrFlNm = .SelectedItems(1)
Else
Exit Sub
End If
End With
Application.Volatile
For Each cBox In ActiveSheet.CheckBoxes
If cBox.Value = 1 Then
iCtr = iCtr + 1
End If
Next cBox
CheckedCount = iCtr
End Sub
它会选择文件,但没有任何反应。如果我能确定如何将其应用于一个复选框,我应该能够弄清楚如何完成其余的工作。我会随着我们继续更新代码,我已经更改了很多次。
激活 Microsoft Object 并运行新代码。选择文件后,系统会提示我此消息。
【问题讨论】: