Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-27-2017, 07:01 AM
mihnea96 mihnea96 is offline Adding tab in Ribbon Windows 7 32bit Adding tab in Ribbon Office 2016
Novice
Adding tab in Ribbon
 
Join Date: Apr 2017
Posts: 26
mihnea96 is on a distinguished road
Default Adding tab in Ribbon

Hi ,
I'm trying to add a custom tab in the ribbon using the below code (which i've also used for Excel with little modifications and it worked) and it doesn't work. the problem is that it runs and doesn't give any error but the ribbon is not in the document. I've also tried to put the file in the "\AppData\Local\Microsoft\Office\" folder but doesn't do anything. Could you kindly help me, please?
Thanks!



Code:
Sub test()

Dim wd As word.Application
Dim Doc As word.Document
Dim VBP As Object, VBC As Object, CM As Object, FM As Object
    Dim strProcName As String
   Set wd = CreateObject("Word.Application")
   wd.Visible = True
   Set Doc = wd.Documents.Add

Dim hFile As Long
Dim path As String, fileName As String, ribbonXml As String, User As String

hFile = FreeFile
User = Environ("HomePath")
path = "C:" & User & "\AppData\Local\Microsoft\Office\"
fileName = "Word Customizations.officeUI"
    
ribbonXml = "<mso:customUI      xmlns:mso='http://schemas.microsoft.com/office/2009/07/customui'>" & vbNewLine
ribbonXml = ribbonXml + "  <mso:ribbon>" & vbNewLine
ribbonXml = ribbonXml + "    <mso:qat/>" & vbNewLine
ribbonXml = ribbonXml + "    <mso:tabs>" & vbNewLine
ribbonXml = ribbonXml + "      <mso:tab id='mso_c1.109B239D' label='Formatting' insertBeforeQ='mso:TabDeveloper'>" & vbNewLine
ribbonXml = ribbonXml + "        <mso:group id='mso_c2.109B239D' label='Export' imageMso='ViewFullScreenView' autoScale='true'>" & vbNewLine
ribbonXml = ribbonXml + "          <mso:button id='x1:startExport_0_109F2716' " & vbNewLine
ribbonXml = ribbonXml + "imageMso='ViewFullScreenView'onAction='startExport' visible='true'/>" & vbNewLine
ribbonXml = ribbonXml + "        </mso:group>"
ribbonXml = ribbonXml + "      </mso:tab>" & vbNewLine
ribbonXml = ribbonXml + "    </mso:tabs>" & vbNewLine
ribbonXml = ribbonXml + "  </mso:ribbon>" & vbNewLine
ribbonXml = ribbonXml + "</mso:customUI>"
    
Open path & fileName For Output Access Write As hFile
Print #hFile, ribbonXml
Close hFile
Reply With Quote
 

Tags
import ribbon in word, ribbon in vba, word ribbon



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding tab in Ribbon too many clicks with ribbon - ribbon content disappears Rewster Word 2 05-12-2017 08:19 AM
Adding a New Ribbon Tab using XML Script rdross51 Word VBA 1 06-12-2016 04:52 AM
How to import the customized ribbon to Word without overwriting the existing Ribbon? SharonSh Word VBA 0 09-26-2013 11:47 PM
Excel 2010 Ribbon look like 2007's Ribbon esotop Excel 0 03-22-2011 07:05 PM
Adding tab in Ribbon Lost Ribbon Tab bigred17 Word 6 09-24-2009 09:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft