Solved

VB.Net word ribbon customization in an app

Posted on 2010-09-08
5
1,075 Views
Last Modified: 2012-08-13
I am working on an application that will work with a word application .
So in my vb code a create an new word applicaton and I load a document into it,
Under the solution I have another project whic is word 2007 addin, where I customize the Ribbon.xml file to disable somw word menues and add some tabs.
The problem is as soon as I compile the application , if I launch an independent instance of word from the program files, the word would have all my customization for the ribbon.
How do I keep the customization local to my solution; i.e only the word laucned by my application to be customized and ant word launched manually to have a default template

what is document level customization project? It seems that the word 2007 addin is an application level customization.

There is some suggestions here
http://stackoverflow.com/questions/294859/ribbon-instances-per-document but hwat kind of project to I need to create?

Thank you
0
Comment
Question by:xav056
  • 3
5 Comments
 
LVL 9

Author Comment

by:xav056
Comment Utility

If I am doing it wrong what type oif project do I create
word 2007 document , word 2007 template or word 2007 addin.
Again what I am looking for is to be able to open a document from my windows form with a ribbon

0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
Comment Utility
YOu are correct Add-in is global app, so all Word 2007 documents will see your ribbon.
>>what is document level customization project?, check:
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/f02831c0-4e26-471f-8736-6a24473422e1
From link: "When you develop a document-level customization, the code will only be loaded and executed when a particular Office document is opened by the end user"

Thus:
You need to use the project "Word 2007 template" if you are planning to use your functionality to generate word documents based in a common functionality. (e.g invoices)
http://code.msdn.microsoft.com/generateinvoicesvsto

Note : You use the project "Word 2007 document" if you are planning to use the word document as for example a report that refresh itself, you can use the ribbon and document surface (like a winform)
http://www.devx.com/dotnet/Article/32114/0/page/2

0
 
LVL 9

Author Comment

by:xav056
Comment Utility
Hello mas_oz2003:
I already took that path (using a word 2007 template), however I am not sure how to load this template to an existing document
So if I had a docx saved somewhere I would like to have the custom ribbon applied to this docs, is there a way that I would force the docx to open in the dotx, again all i need is the frame(UI) of the dotx) and the content of the .docx to be together.

Thank you
0
 
LVL 9

Author Comment

by:xav056
Comment Utility
I already tried
doc=wordApp.documents.add(path,false,0,true)
doc.attachedTemplated="PthtoTemplate"
but the ribbon is not customized when this is done

Thank you
0
 
LVL 6

Expert Comment

by:xenacode
Comment Utility
You can create the addin and deploy it then disable it i.e. set LoadBehavior to 0 in the registry. This way your addin will never load unless requested. Your standalone application that automates Word can then force the addin to load. You can access the add-ins whether loaded or not through the Word.Application object. The Connect property determines if the addin is loaded. So if "wordApp" is your reference to the Word Application object, you can do something like this:

for each addin as Micorosft.Office.Core.COMAddin in wordApp.COMAddins
    if addin.ProgID = "MyAddInName" then
        addin.Connect = True
        Exit For
    End If
Next

Inside your addin Startup code, you can manipulate the ribbons.

Good luck

Pete
Xenacode Ltd
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now