Acess a Word-Dropdown List from Excel VBA

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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I've found out myself. It was
AppWdDoc.Sections(1).Headers(2).Range.ContentControls(1).Range.Text = CellText
 
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top