사용자 입력을 수집 한 Access 데이터베이스를 코딩 한 다음 Word 문서를 열고 문서의 다양한 부분을 채 웁니다.VBA DropDownList ContentControls에 대한 개체 코드 액세스
내가 겪고있는 문제는 드롭 다운 목록에서만 한 번 작동한다는 것입니다. 이 문제를 해결할 이유 또는 위치를 잘 모릅니다. 프로그래밍 방식으로 채우는 항목에는 세 가지 유형이 있습니다. 첫 번째 항목은 책갈피입니다. 둘째로 Content Control Checkbox는 문제없이 작동합니다. 세 번째는 콘텐츠 제어 드롭 다운 목록입니다. 여기가 문제입니다. 처음으로 Access 데이터베이스를 열었지만 명령 단추를 다시 누르면 아무 것도 표시되지 않습니다 (드롭 다운의 경우). 가장 큰 문제점은 오류 메시지가 나타나지 않아 어디서 볼 것인지 잘 모르겠다는 것입니다.
내가 드롭 다운 업데이트를 만들기 위해 만든 객체와 관련이 있다고 생각합니까? 모든 도움이 될 것입니다 :
Dim WordApp As Word.Application
Dim strTemplateLocation As String
Dim dir As String
Dim path As String
Dim wDoc As Word.Document
path = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
strTemplateLocation = path & "UserDoc.docx"
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set WordApp = CreateObject("Word.Application")
End If
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
WordApp.Documents.Add Template:=strTemplateLocation, newtemplate:=False
With WordApp
'Working Bookmark
.Selection.GoTo what:=wdGoToBookmark, Name:="COMPANY": .Selection.TypeText [fac]
'Working checkbox
If Me.RD = True Then: .ActiveDocument.ContentControls(9).Checked = True
'Works ONCE drop down
Dim objCC As ContentControl
Dim objCE As ContentControlListEntry
Dim ListSelection As String
ListSelection = Me.System_Type.ListIndex + 2
Set objCC = ActiveDocument.ContentControls(1): Set objCE = objCC.DropdownListEntries.Item(ListSelection): objCE.Select
End With
끝 부분에 objCE 및 objCC를 닫아야합니까? 그것은
Set objCC = .ActiveDocument.ContentControls(1)
그러나 훨씬 더 될 것이라고해야
Set objCC = ActiveDocument.ContentControls(1)
:
환상적인! 무리 감사. –