Devagorgon
New Member
- Joined
- Sep 25, 2018
- Messages
- 13
Hello,
I am sitting on an Excel VBA-script, that opens a Word Document and fills out some Cells in a Table located in the Word Header with values it reads from an Excel File.
So Far it works using code like
Dim oConvWB As Workbook
Set oConvWB = Workbooks.Open(TextBox_ExcelPath.Text)
Dim AppWord As Object
Set AppWord = CreateObject("Word.Application")
Dim AppWdDoc As Object
Set AppWdDoc = AppWord.Documents.Open(TextBox_WordPath.Text)
oConvWB.Sheets("Header").Select
Dim CellText As String
CellText = oConvWB.Sheets("Header").Range(Cells(2, 2), Cells(2, 2)).Text
AppWdDoc.Sections(1).Headers(1).Range.Tables(1).Cell(1, 3).Range.InsertAfter CellText
The problem is, Cell(3.2) in the Word document header contains a Dropdown-List-Element, which I have to set accordingly, but I don't know how to access it.
Can someone tell me the right way to acces the list and set the element?
Furthermore, in addition to searching the web, i have tried to display the local window in VBA and look at the Properties of AppWdDoc myself, but I cannot comprehend, what I am seeing. Could someone give me a quick intro on how to find special objects like fields, tables, dropdown list, etc in header and body and their respective names? (Then maybe I can find out myself next time)
Thanks
I am sitting on an Excel VBA-script, that opens a Word Document and fills out some Cells in a Table located in the Word Header with values it reads from an Excel File.
So Far it works using code like
Dim oConvWB As Workbook
Set oConvWB = Workbooks.Open(TextBox_ExcelPath.Text)
Dim AppWord As Object
Set AppWord = CreateObject("Word.Application")
Dim AppWdDoc As Object
Set AppWdDoc = AppWord.Documents.Open(TextBox_WordPath.Text)
oConvWB.Sheets("Header").Select
Dim CellText As String
CellText = oConvWB.Sheets("Header").Range(Cells(2, 2), Cells(2, 2)).Text
AppWdDoc.Sections(1).Headers(1).Range.Tables(1).Cell(1, 3).Range.InsertAfter CellText
The problem is, Cell(3.2) in the Word document header contains a Dropdown-List-Element, which I have to set accordingly, but I don't know how to access it.
Can someone tell me the right way to acces the list and set the element?
Furthermore, in addition to searching the web, i have tried to display the local window in VBA and look at the Properties of AppWdDoc myself, but I cannot comprehend, what I am seeing. Could someone give me a quick intro on how to find special objects like fields, tables, dropdown list, etc in header and body and their respective names? (Then maybe I can find out myself next time)
Thanks