none
Open/Edit/Save Word Document using VB Scripts RRS feed

  • Question

  • Hi,

    We have a very old VB script which uses the COM components to create/edit and save word document.

    We installed Microsoft Office 2010: Primary Interop Assemblies Redistributable on our VM and ran the scripts. The application was working without having any issues. 

    We want to use the Microsoft Office 2013:Primary Interop Assemblies Redistributable but I couldn't find any. We are upgrading our Windows Server to 2012 on which the Office 2010 PIA's will not work. 

    Is there any way to use the COM components of VB Scripts to create documents without the PIA's?

    Thank you,

    Nirmala

    Thursday, June 18, 2015 8:15 PM

Answers

  • Hi Nirmala

    (For the exact answer to your question, see the end, after all the explanation about PIAs and Office versions.)

    Mmm, Edward's reply is not completely accurate...

    It's not clear from your problem description whether Office has been installed on Windows Server 2012 and whether your code is supposed to be automating Office server-side, or on a desktop machine? If server-side, you should be aware that this is not supported by Microsoft and look at an alternative (usually leveraging the Open XMl file format).

    The Office 2010 PIAs should work no matter which OS is installed, but they are Office-version specific - you cannot use the Office 2010 PIAs with Office 2013.  But, as Edward says, installing Office should install the correct set of PIAs for the installed version.

    If you compile .NET code against the 2010 PIAs, then use your solution with a later version of Word, the Office functionality should automatically "re-map" the 2010 reference to the later version's PIAs. So code compiled against the Office 2010 PIAs should run on a machine where Office 2013 is installed. Note that the PIAs, alone, are NOT enough to "run" Office - the Office applications MUST be installed.

    Also, it's not necessary to use the PIAs. You can use tlbimp.exe to create your own set of IAs that you distribute with your solution. In that case, your solution does not reference any of the Microsoft PIAs, only its own. But sometimes the IAs "translate" the COM object model differently than the optimized PIAs and you need to code around that.

    It's also possible to avoid using any references at all to IAs and work with "late binding" (PInvoke). This can be a headache to code as it requires in-depth knowledge of the object model - there's no intellisense or compiler checking, all errors return when the code is run and the information is not very helpful!


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, June 20, 2015 6:03 PM
    Moderator

All replies

  • Hi Nirmala,

    >>We want to use the Microsoft Office 2013:Primary Interop Assemblies Redistributable but I couldn't find any.

    It seems that there is no Office 2013 Primary Interop Assemblies Redistributable. When you install Office 2013, the PIA will be installed.

    >> We are upgrading our Windows Server to 2012 on which the Office 2010 PIA's will not work.

    you get any error message when you use Office 2010 or Office 2013? Could you share us your system environment? Did you uninstall Office 2010 and install Office 2013 or upgrade Office 2010 to Office 2013?
    >
    > Is there any way to use the COM components of VB Scripts to create documents without the PIA's?

    No, it is impossible. If you want to use Office Automation, you need PIAs.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, June 19, 2015 8:36 AM
  • Hi Nirmala

    (For the exact answer to your question, see the end, after all the explanation about PIAs and Office versions.)

    Mmm, Edward's reply is not completely accurate...

    It's not clear from your problem description whether Office has been installed on Windows Server 2012 and whether your code is supposed to be automating Office server-side, or on a desktop machine? If server-side, you should be aware that this is not supported by Microsoft and look at an alternative (usually leveraging the Open XMl file format).

    The Office 2010 PIAs should work no matter which OS is installed, but they are Office-version specific - you cannot use the Office 2010 PIAs with Office 2013.  But, as Edward says, installing Office should install the correct set of PIAs for the installed version.

    If you compile .NET code against the 2010 PIAs, then use your solution with a later version of Word, the Office functionality should automatically "re-map" the 2010 reference to the later version's PIAs. So code compiled against the Office 2010 PIAs should run on a machine where Office 2013 is installed. Note that the PIAs, alone, are NOT enough to "run" Office - the Office applications MUST be installed.

    Also, it's not necessary to use the PIAs. You can use tlbimp.exe to create your own set of IAs that you distribute with your solution. In that case, your solution does not reference any of the Microsoft PIAs, only its own. But sometimes the IAs "translate" the COM object model differently than the optimized PIAs and you need to code around that.

    It's also possible to avoid using any references at all to IAs and work with "late binding" (PInvoke). This can be a headache to code as it requires in-depth knowledge of the object model - there's no intellisense or compiler checking, all errors return when the code is run and the information is not very helpful!


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, June 20, 2015 6:03 PM
    Moderator