Unable to export to PDF

Export to PDF: Unable to cast COM object of type ‘Microsoft.Office.Interop.Word.DocumentClass’ to interface type ‘Microsoft.Office.Interop.Word._Document’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{0002096B-0000-0000-C000-000000000046}’ failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
Please help me in this issue. Give your ideas.

can you try installing “Microsoft.Office.Interop.Word” from the imports section

Thanks for the response

Actually I need to create a word file and also pdf file from the raw text file
Can u please help.