Improve company productivity with a Business Account.Sign Up

x
?
Solved

VB.Net word ribbon customization in an app

Posted on 2010-09-08
5
Medium Priority
?
1,143 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
ID: 33637447

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 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 33651077
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
ID: 33663861
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
ID: 33664014
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
ID: 33732479
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

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

608 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