Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / April 2006

Tip: Looking for answers? Try searching our database.

How to integrate multiple word templates in single user interface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kausar - 03 Apr 2006 13:03 GMT
Hello All,
Basically I need to provide multiple word templates but with the single
interface.

Should i have to make separate solutions for each templates?

Should i have to make separate projects in a single solution?

If yes how to integrate all the templates by providing single user
interface?

I want to open the blank docment with action pane which will provide the
list of the other word templates. On the selection one of the word template
from the list, i want to open the document based on that template.

or How can i make a single application/Setup that embeds multiple word
templates?

how can i achieve this?

Thanks in advance.

Best Regards

Kausar
Richard Hogan - 04 Apr 2006 16:04 GMT
Hi Kausar

I am in the process of developing a similar solution, I can't say if it is
the best way but below you will find an outline of the solution that I
developed.

1 x Windows App (This could be the interface for opening documents or in my
case for administration)
1 x User Control (Action Pane)
1 x Word Add In (In my solution this creates a toolbar which is used to open
the docs)
? x multiple word docs\templates
1 x SQL database (holds document locations, names etc..)

All of the above is basically in one solution, split into separate projects.
I did set all of the template\document projects output paths to the same
location, this seemed to simplify the document open routines.

It sounds like you might want to create the action pane as part of a "word
add in" so it loads every time word does.

I hope this helps.

regards

Richard
Kausar Parveen - 05 Apr 2006 09:11 GMT
Hello Richard,

           First of all i must appreciate you for understanding my problem
excatly the same way as all i wanted. I also figured it out the same way as
you did but I am stucked up at unable to open the word documents from the
toolbar. Also my solution don't contains the User Control (Action
pane ).what it does and what will be it's purpose?
If possible can i have your code please? Waiting for your positive response.

Best Regards
Kausar

> Hi Kausar
>
[quoted text clipped - 22 lines]
>
> Richard
Richard Hogan - 05 Apr 2006 11:51 GMT
Hi Kauser

I will reproduce the code I used to create the toolbars and open the
documents, some of the code references other classes which I have not
reproduced here.  However these are generally speaking dataaccess classes,
which will not be relevant for this example.  I set this up as a module, but
it could be added to a class or I suppose directly in the connect.vb.

As to the action pane, I am using this so that the user can add data to the
templates once they have been opened, such as addresses, signatures,
telephone numbers etc.. this is retreived from a seperate contacts database.  
However in your original post you mentioned using an action pane to open the
documents, so I have also included some code at the bottom of this post which
will allow you to add a user defined task pane to a document.

I hope that this prooves useful

Cheers

Richard

TOOLBAR CODE

Imports Microsoft.Office.Core
Module modWord
   ' Declare the menu variable at the class level.
   Private cDocs As New BLL.clsDocuments
   'Creates an array of base toolbar buttons, these are to be set up as
popup style controls
   Dim cbButton(6) As CommandBarControl
   'Creates an array of toolbar buttons - to be added to the main drop down
buttons
   Private btn(50) As CommandBarButton
   Dim cb As CommandBar
   'declares Word Application
   Private wApp As Microsoft.Office.Interop.Word.Application
   Dim intIndex As Integer = 0

   Sub CreateMenu(ByVal applicationObject As
Microsoft.Office.Interop.Word.Application)
       'Creates Office Toolbar
       Dim strMenuName As String = "Custom Tools"
       wApp = applicationObject
       cb = wApp.CommandBars.Add(strMenuName, 1, False, True)
       'Creates the 4 main toolbar buttons, all other buttons will be drop
down buttons,
       'attached to these.
       cbButton(1) = cb.Controls.Add(MsoControlType.msoControlPopup, , , ,
True)
       cbButton(2) = cb.Controls.Add(MsoControlType.msoControlPopup, , , ,
True)
       cbButton(3) = cb.Controls.Add(MsoControlType.msoControlPopup, , , ,
True)
       cbButton(4) = cb.Controls.Add(MsoControlType.msoControlPopup, , , ,
True)
       'Set button properties
       With cbButton(1)
           .Caption = "&Letters && Faxes"
           .Tag = "Letters"
           .BeginGroup = False
       End With
       With cbButton(2)
           .Caption = "&Other Documents"
           .Tag = "Other Documents"
           .BeginGroup = False
       End With
       With cbButton(3)
           .Caption = "&Printing Options"
           .Tag = "Printing Options"
           .BeginGroup = False
       End With
       With cbButton(4)
           .Caption = "&London Print"
           .Tag = "London Options"
           .BeginGroup = False
       End With
       'Create dataset which will hold the information to build the
       'drop down items.
       Dim dsCommandBarItems As New DataSet
       Dim intLooper As Integer = 1
       'Loop through the database and extract information for each
       'drop down toolbar button.
       For intLooper = 1 To 4
           'Reference Class to retreive data from database
           dsCommandBarItems = cDocs.CreateCommandBar(intLooper)
           Dim intLoop As Integer
           With dsCommandBarItems.Tables(0)
               'For each document in database, retrieves the document info
               'and passes it to the method to create the toolbar button
               For intLoop = 0 To .Rows.Count - 1
                   AddButton(.Rows(intLoop).Item("Caption").ToString, _
                       CInt(.Rows(intLoop).Item("Image").ToString), _
                       cbButton(intLooper),
CInt(.Rows(intLoop).Item("DocumentID").ToString), _
                       CBool(.Rows(intLoop).Item("BeginGroup").ToString))
                   intIndex += 1
               Next
           End With
       Next
       cb.Visible = True
       cb = Nothing
   End Sub

   Private Sub ButtonClick(ByVal ctrl As CommandBarButton, ByRef Cancel As
Boolean)
       Try
           'Opens Document - passes documentID to database, which in turn
returns the path to the document
           wApp.Documents.Add(cDocs.GetDocumentPath(CInt(ctrl.Tag)))
       Catch ex As Exception
           MsgBox("Word was unable to open the document, check that the
document exists and try again", MsgBoxStyle.Information, "Template Error")
       End Try
   End Sub

   Private Sub AddButton(ByVal strCaption As String, ByVal intFaceID As
Integer, ByVal objCommandBar As Object, ByVal intDocumentID As Integer, ByVal
bhasGroup As Boolean)
       btn(intIndex) =
CType(objCommandBar.Controls.Add(MsoControlType.msoControlButton),
CommandBarButton)
       With btn(intIndex)
           'Sets toolbar button caption
           .Caption = strCaption
           'Sets toolbar button image
           .FaceId = intFaceID
           'Set toolbar tag to = document ID, will be used later to
retreive document path from database
           .Tag = Str(intDocumentID)
           'Set the begingroup variable
           .BeginGroup = bhasGroup
       End With
       'Adds handler for the toolbar.button click event
       AddHandler btn(intIndex).Click, AddressOf ButtonClick
   End Sub
End Module

ACTION PANE CODE

'Adds a reference to the user control
Imports WindowsControlLibrary1

Public Class ThisDocument

   Private WithEvents ucTaskPane As TaskPane

   Private Sub ThisDocument_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
       ucTaskPane = New TaskPane(Me)
       Me.ActionsPane.Controls.Add(ucTaskPane)
   End Sub

End Class
Kausar Parveen - 05 Apr 2006 13:19 GMT
Hello Richard,

       Thanks a lot for your instant reply and that too positive:-) Let me
checkout your code and i'll get back to you.

Best Regards
Kausar

> Hi Kauser
>
[quoted text clipped - 149 lines]
>
> End Class

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.