[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1134
  • Last Modified:

VB.Net word ribbon customization in an app

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
xav056
Asked:
xav056
  • 3
1 Solution
 
xav056Author Commented:

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
 
Miguel OzSoftware EngineerCommented:
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
 
xav056Author Commented:
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
 
xav056Author Commented:
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
 
xenacodeCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now