Forum Discussion
PacoDeBenito
Jun 27, 2023Copper Contributor
Can't access Word objects from Excel VBA code
Hello! I'm trying to write in a Word document from Excel VBA code, to place the data from am Excel table into a report. I added the "Microsoft Office 16.0 Object Library" to be able to work with Wor...
NikolinoDE
Jul 02, 2023Gold Contributor
The issue you are experiencing with accessing Word objects from Excel VBA code could be related to a few different factors. Here are some troubleshooting steps you can try:
- Confirming the correct reference: Ensure that you have added the correct reference to the Word Object Library in Excel VBA. While the library file may not be named "MSO.DLL" directly, it should still be available for selection. Look for "Microsoft Word x.x Object Library" in the list of available references (where "x.x" represents the version number).
- Reference path discrepancy: The file path you mentioned ("C:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE16\MSO.DLL") indicates the 64-bit version of Office, which might not be the version installed on your computer. It is possible that you have the 32-bit version of Office installed, which would have a different file path. You can check the correct path by going to the "Tools >> References..." dialog box in Excel VBA, selecting the Word Object Library, and noting the "Location" field at the bottom of the dialog.
- Language-specific file names: The folder name "Archivos de Programa (x86)" instead of "Program Files (x86)" in your system should not cause any issues with referencing the Word Object Library. The folder names may be localized, but the libraries and references should still be accessible.
- Repair or reinstall Office: If you are unable to find the correct reference or the Word Object Library is missing, it's possible that your Office installation might be corrupted. In such cases, you can try repairing or reinstalling Office to ensure that all necessary files and libraries are in place. The texts and steps were created by the AI.