fbpx

Combining Multiple Office Tool Bars (olkexplorer.officeUI)

Alienware PC's

Hi! Today we are going to have a post on a more specific and technical topic. I recently found a need to combine a customized Microsoft Office 2016 Outlook tool bar with the user’s existing tool bar – also know as olkexplorer.officeUI. The easy route would be to just force the end user to use the customized bar and loose their existing changes. However, we want to provide the highest level of customer service so we need to keep our end users happy! I spent significant time looking at other forum postings and found no one really covered this topic – hence, I hope this post saves someone a few hours worth of time (or more)!

CAUTION! It is recommended that you have a good understanding of PowerShell and XML prior to working with this code. If you have any questions – please visit the contact section or level a note in the comments.

Now for the fun stuff!

$path_to_office = “$env:USERPROFILE\AppData\Local\Microsoft\Office”

if (-NOT (Test-Path “$path_to_office\olkexplorer.officeUI”))
{
Copy-Item “\\NETWORKSHARE\generic_olkexplorer.officeUI” “$path_to_office\olkexplorer.officeUI”
}

Copy-Item “$path_to_office\olkexplorer.officeUI” “$path_to_office\olkexplorer.officeUI.BAK”

Remove-Item “$path_to_office\olkexplorer.officeUI”

$input = [xml](Get-Content -Path “$path_to_office\olkexplorer.officeUI.BAK”)
$output =[xml](Get-Content “\\NETWORKSHARE\customtoolbar.officeUI”)

Foreach ($Node in $input.customUI.ribbon.tabs.tab)
{
$output.customUI.ribbon.tabs.AppendChild($output.ImportNode($Node, $true))
}

$output.Save(“$path_to_office\olkexplorer.officeUI”)

Great, thanks for visiting, enjoy! Just kidding – let me give you a quick run down of what is going on above.

First, we need to set a variable to the install location of Microsoft Office on the end users computer where we can find olkexplorer.officeUI.

Next, if the user does NOT have a customized toolbar – let’s copy a generic olkexplorer.officeUI from a network share to the local machine. We need to have a generic one to combine our customized toolbar into.

Next, since we are good system administrators – we need a way to get ourselves out of trouble. Therefor, let’s copy the users existing toolbar for backup and then delete the source.

Finally, the last part is our secret sauce – the fun stuff! We take the users Office toolbar and combine it with our custom Office toolbar using PowerShell’s wonderful built in XML interpreter and save the output.

Done!

8 thoughts on “Combining Multiple Office Tool Bars (olkexplorer.officeUI)”

  1. Hi,

    I can’t get it work! I always get an InvalidCastToXmlDocument Exception. Could you please provide the source XML of your customtoolbar.officeUI and generic_olkexplorer.officeUI. Seems that mine is not good… (I exported them from Outlook)

    1. Hi there. How did you export from Outlook? All you should need to do is copy the raw file from the location in the script above! Talk soon.

  2. edit the script posted above to replace ” with ” – it’s a common issue copying a script from a webpage that it has the wrong quotation / speech marks character

  3. Hi

    Very cool idea since Microsoft didnt leave an option to import only changes or additions.. (*rollseyes*).

    But I am getting an error in the script:

    on the part:
    $input = [xml](Get-Content “$path_to_office\olkexplorer.officeUI.BAK”)
    $output =[xml](Get-Content “$path\customtoolbar.officeUI”)

    I get errors:

    Cannot convert value “” to type “System.Xml.XmlDocument”. Error: “‘mso’ is an undeclared prefix. Line 1, position 2.”
    At line:1 char:1
    + $input = [xml](Get-Content “$path_to_office\olkexplorer.officeUI.BAK” …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastToXmlDocument

    Cannot convert value “” to type “System.Xml.XmlDocument”. Error: “‘mso’ is an undeclared prefix. Line 1, position
    2.”
    At line:2 char:1
    + $output =[xml](Get-Content “$path\customtoolbar.officeUI”)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastToXmlDocument

    1. Hi Dejan. See Simon’s comment above! I will change the post to make it more cut and paste friendly. 🙂

  4. Hi,

    Nice script!
    Is there a way to do exactly this in a batch file?
    Due to comp. policies, powershell scripts are not allowed.

      1. Great, to answer your original question, I doubt it. PowerShell has built in logical for XML files so you would need to find an alternative solution. Cheers!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top