Group:  Microsoft Word ยป microsoft.public.word.vba.addins
Thread: How to create a MS Word Add in

Geek News

How to create a MS Word Add in
Zaid Papa 5/21/2007 4:41:00 PM
Hi,
I want to create a MS Word Add in which should contain a dropdown menu. I
googled for some time to learn how to create a word add- in as i have never
done this before. But i could not find a proper article which explains
exactly how to create a add-in. Hence can anybody help me in this!
Thanks
Zaid Papa
Re: How to create a MS Word Add in
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 5/21/2007 5:14:36 PM
To create an add in, you save a template in the Word Startup folder, the
location of which you can determine via Tools>Options>File Locations.

To find out about adding toolbars, see the article "How to assign a Word
command or macro to a toolbar or menu" at:

http://www.word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm

and take a look at some of the other articles on that site to do with
toolbars.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
news:894F55BC-22DF-4AB3-AEA9-85CC8B23B6E1[ at ]microsoft.com...
[Quoted Text]
> Hi,
> I want to create a MS Word Add in which should contain a dropdown menu. I
> googled for some time to learn how to create a word add- in as i have
> never
> done this before. But i could not find a proper article which explains
> exactly how to create a add-in. Hence can anybody help me in this!
> Thanks
> Zaid Papa


Re: How to create a MS Word Add in
Zaid Papa 5/21/2007 6:07:01 PM
Basically this is what i want to do.
I am trying to create a drop down menu in MS Word 2003, which will display a
list of names [ i am using these names as the signature of the document,
which means if a letter has been written by Mr.Smith, by using the drop down
menu i should be able to select Mr.Smith, and Mr.Smith`s e-sign should be
loaded at the last page of the document]. I do not know how to do this, but
had i guess that the add-in will be a good way to do it. If there is any
other way of doing it, kindly tell me.
Hope you understood what i am trying to say.


"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> To create an add in, you save a template in the Word Startup folder, the
> location of which you can determine via Tools>Options>File Locations.
>
> To find out about adding toolbars, see the article "How to assign a Word
> command or macro to a toolbar or menu" at:
>
> http://www.word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm
>
> and take a look at some of the other articles on that site to do with
> toolbars.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
> news:894F55BC-22DF-4AB3-AEA9-85CC8B23B6E1[ at ]microsoft.com...
> > Hi,
> > I want to create a MS Word Add in which should contain a dropdown menu. I
> > googled for some time to learn how to create a word add- in as i have
> > never
> > done this before. But i could not find a proper article which explains
> > exactly how to create a add-in. Hence can anybody help me in this!
> > Thanks
> > Zaid Papa
>
>
>
Re: How to create a MS Word Add in
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 5/21/2007 8:39:12 PM
This would better be done by having a userform in the template that is used
to create the letter. In addition to displaying a combobox from which the
user could select the signatory, it could also contain controls into which
the user could enter/select the recipeint, their address details (either
manually or automatically based on the recipient selected, the subject of
the letter, etc.

See the article "How to create a Userform" at:

http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

This routine loads a listbox (or combobox) with client details stored in a
table in a separate
document (which makes it easy to maintain with additions, deletions etc.),
that document being saved as Clients.Doc for the following code.

On the UserForm, have a list box (ListBox1) and a Command Button
(CommandButton1) and use the following code in the UserForm_Initialize() and
the CommandButton1_Click() routines

Private Sub UserForm_Initialize()
Dim sourcedoc As Document, i As Integer, j As Integer, myitem As Range,
m As Long, n As Long
' Modify the path in the following line so that it matches where you
saved Clients.doc
Application.ScreenUpdating = False
' Open the file containing the client details
Set sourcedoc = Documents.Open(FileName:="e:\worddocs\Clients.doc")
' Get the number or clients = number of rows in the table of client
details less one
i = sourcedoc.Tables(1).Rows.Count - 1
' Get the number of columns in the table of client details
j = sourcedoc.Tables(1).Columns.Count
' Set the number of columns in the Listbox to match
' the number of columns in the table of client details
ListBox1.ColumnCount = j
' Define an array to be loaded with the client data
Dim MyArray() As Variant
'Load client data into MyArray
ReDim MyArray(i, j)
For n = 0 To j - 1
For m = 0 To i - 1
Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
myitem.End = myitem.End - 1
MyArray(m, n) = myitem.Text
Next m
Next n
' Load data into ListBox1
ListBox1.List() = MyArray
' Close the file containing the client details
sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
End Sub

Private Sub CommandButton1_Click()
Dim i As Integer, Addressee As String
Addressee = ""
For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Addressee = Addressee & ListBox1.Value & vbCr
Next i
ActiveDocument.Bookmarks("Addressee").Range.InsertAfter Addressee
UserForm2.Hide
End Sub

The Initialize statement will populate the listbox with the data from the
table and then when a client is selected in from the list and the command
button is clicked, the information for that client will be inserted into a
bookmark in the document. You may want to vary the manner in which it is
inserted to suit our exact requirements, but hopefully this will get you
started.

To make it easy for you, the code has been written so that it will deal with
any number of clients and any number of details about each client. It
assumes that the first row of the table containing the client details is a
header row.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
news:27C327BA-46A8-45EE-B913-A984423393DA[ at ]microsoft.com...
[Quoted Text]
> Basically this is what i want to do.
> I am trying to create a drop down menu in MS Word 2003, which will display
> a
> list of names [ i am using these names as the signature of the document,
> which means if a letter has been written by Mr.Smith, by using the drop
> down
> menu i should be able to select Mr.Smith, and Mr.Smith`s e-sign should be
> loaded at the last page of the document]. I do not know how to do this,
> but
> had i guess that the add-in will be a good way to do it. If there is any
> other way of doing it, kindly tell me.
> Hope you understood what i am trying to say.
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> To create an add in, you save a template in the Word Startup folder, the
>> location of which you can determine via Tools>Options>File Locations.
>>
>> To find out about adding toolbars, see the article "How to assign a Word
>> command or macro to a toolbar or menu" at:
>>
>> http://www.word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm
>>
>> and take a look at some of the other articles on that site to do with
>> toolbars.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
>> news:894F55BC-22DF-4AB3-AEA9-85CC8B23B6E1[ at ]microsoft.com...
>> > Hi,
>> > I want to create a MS Word Add in which should contain a dropdown menu.
>> > I
>> > googled for some time to learn how to create a word add- in as i have
>> > never
>> > done this before. But i could not find a proper article which explains
>> > exactly how to create a add-in. Hence can anybody help me in this!
>> > Thanks
>> > Zaid Papa
>>
>>
>>


Re: How to create a MS Word Add in
Zaid Papa 5/22/2007 1:00:01 PM
Hi Doug,
Let me explain to you whats going on at my site.
We have a letter document in MS Word, where we insert an e-sign of the
person [ from whom the letter is being sent] using Macros. This was feasible
for one person. But now we have too many names, and we are finding it very
difficult to use Macros, inorder to insert the e-sign.
Hence i thought that we should try to put a Add-In with a drop down, which
lists all the names, and the moment we select a particular name say Mr.Smith,
then the e-sign of Mr.Smith must be inserted at the end of the page.
I do not know whether this can be done with Add-Ins, i do not think so it
is feasible to do with forms, as we just need to load the e-sign and nothing
else.
Hence if you know of any better way by which this can be done, it will be
great.
Thanks

"Doug Robbins - Word MVP" wrote:

[Quoted Text]
> This would better be done by having a userform in the template that is used
> to create the letter. In addition to displaying a combobox from which the
> user could select the signatory, it could also contain controls into which
> the user could enter/select the recipeint, their address details (either
> manually or automatically based on the recipient selected, the subject of
> the letter, etc.
>
> See the article "How to create a Userform" at:
>
> http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm
>
> This routine loads a listbox (or combobox) with client details stored in a
> table in a separate
> document (which makes it easy to maintain with additions, deletions etc.),
> that document being saved as Clients.Doc for the following code.
>
> On the UserForm, have a list box (ListBox1) and a Command Button
> (CommandButton1) and use the following code in the UserForm_Initialize() and
> the CommandButton1_Click() routines
>
> Private Sub UserForm_Initialize()
> Dim sourcedoc As Document, i As Integer, j As Integer, myitem As Range,
> m As Long, n As Long
> ' Modify the path in the following line so that it matches where you
> saved Clients.doc
> Application.ScreenUpdating = False
> ' Open the file containing the client details
> Set sourcedoc = Documents.Open(FileName:="e:\worddocs\Clients.doc")
> ' Get the number or clients = number of rows in the table of client
> details less one
> i = sourcedoc.Tables(1).Rows.Count - 1
> ' Get the number of columns in the table of client details
> j = sourcedoc.Tables(1).Columns.Count
> ' Set the number of columns in the Listbox to match
> ' the number of columns in the table of client details
> ListBox1.ColumnCount = j
> ' Define an array to be loaded with the client data
> Dim MyArray() As Variant
> 'Load client data into MyArray
> ReDim MyArray(i, j)
> For n = 0 To j - 1
> For m = 0 To i - 1
> Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
> myitem.End = myitem.End - 1
> MyArray(m, n) = myitem.Text
> Next m
> Next n
> ' Load data into ListBox1
> ListBox1.List() = MyArray
> ' Close the file containing the client details
> sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
> End Sub
>
> Private Sub CommandButton1_Click()
> Dim i As Integer, Addressee As String
> Addressee = ""
> For i = 1 To ListBox1.ColumnCount
> ListBox1.BoundColumn = i
> Addressee = Addressee & ListBox1.Value & vbCr
> Next i
> ActiveDocument.Bookmarks("Addressee").Range.InsertAfter Addressee
> UserForm2.Hide
> End Sub
>
> The Initialize statement will populate the listbox with the data from the
> table and then when a client is selected in from the list and the command
> button is clicked, the information for that client will be inserted into a
> bookmark in the document. You may want to vary the manner in which it is
> inserted to suit our exact requirements, but hopefully this will get you
> started.
>
> To make it easy for you, the code has been written so that it will deal with
> any number of clients and any number of details about each client. It
> assumes that the first row of the table containing the client details is a
> header row.
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
> news:27C327BA-46A8-45EE-B913-A984423393DA[ at ]microsoft.com...
> > Basically this is what i want to do.
> > I am trying to create a drop down menu in MS Word 2003, which will display
> > a
> > list of names [ i am using these names as the signature of the document,
> > which means if a letter has been written by Mr.Smith, by using the drop
> > down
> > menu i should be able to select Mr.Smith, and Mr.Smith`s e-sign should be
> > loaded at the last page of the document]. I do not know how to do this,
> > but
> > had i guess that the add-in will be a good way to do it. If there is any
> > other way of doing it, kindly tell me.
> > Hope you understood what i am trying to say.
> >
> >
> > "Doug Robbins - Word MVP" wrote:
> >
> >> To create an add in, you save a template in the Word Startup folder, the
> >> location of which you can determine via Tools>Options>File Locations.
> >>
> >> To find out about adding toolbars, see the article "How to assign a Word
> >> command or macro to a toolbar or menu" at:
> >>
> >> http://www.word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm
> >>
> >> and take a look at some of the other articles on that site to do with
> >> toolbars.
> >>
> >> --
> >> Hope this helps.
> >>
> >> Please reply to the newsgroup unless you wish to avail yourself of my
> >> services on a paid consulting basis.
> >>
> >> Doug Robbins - Word MVP
> >>
> >> "Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
> >> news:894F55BC-22DF-4AB3-AEA9-85CC8B23B6E1[ at ]microsoft.com...
> >> > Hi,
> >> > I want to create a MS Word Add in which should contain a dropdown menu.
> >> > I
> >> > googled for some time to learn how to create a word add- in as i have
> >> > never
> >> > done this before. But i could not find a proper article which explains
> >> > exactly how to create a add-in. Hence can anybody help me in this!
> >> > Thanks
> >> > Zaid Papa
> >>
> >>
> >>
>
>
>
Re: How to create a MS Word Add in
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 5/22/2007 1:59:01 PM
The way I suggested.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Zaid Papa" <ZaidPapa[ at ]discussions.microsoft.com> wrote in message
news:49D5D59B-A45C-4A83-87CE-154D3FDB1EB7[ at ]microsoft.com...
[Quoted Text]
> Hi Doug,
> Let me explain to you whats going on at my site.
> We have a letter document in MS Word, where we insert an e-sign of the
> person [ from whom the letter is being sent] using Macros. This was
> feasible
> for one person. But now we have too many names, and we are finding it very
> difficult to use Macros, inorder to insert the e-sign.
> Hence i thought that we should try to put a Add-In with a drop down, which
> lists all the names, and the moment we select a particular name say
> Mr.Smith,
> then the e-sign of Mr.Smith must be inserted at the end of the page.
> I do not know whether this can be done with Add-Ins, i do not think so it
> is feasible to do with forms, as we just need to load the e-sign and
> nothing
> else.
> Hence if you know of any better way by which this can be done, it will be
> great.
> Thanks
>
> "Doug Robbins - Word MVP" wrote:
>
>> This would better be done by having a userform in the template that is
>> used
>> to create the letter. In addition to displaying a combobox from which
>> the
>> user could select the signatory, it could also contain controls into
>> which
>> the user could enter/select the recipeint, their address details (either
>> manually or automatically based on the recipient selected, the subject of
>> the letter, etc.
>>
>> See the article "How to create a Userform" at:
>>
>> http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm
>>
>> This routine loads a listbox (or combobox) with client details stored in
>> a
>> table in a separate
>> document (which makes it easy to maintain with additions, deletions
>> etc.),
>> that document being saved as Clients.Doc for the following code.
>>
>> On the UserForm, have a list box (ListBox1) and a Command Button
>> (CommandButton1) and use the following code in the UserForm_Initialize()
>> and
>> the CommandButton1_Click() routines
>>
>> Private Sub UserForm_Initialize()
>> Dim sourcedoc As Document, i As Integer, j As Integer, myitem As
>> Range,
>> m As Long, n As Long
>> ' Modify the path in the following line so that it matches where you
>> saved Clients.doc
>> Application.ScreenUpdating = False
>> ' Open the file containing the client details
>> Set sourcedoc = Documents.Open(FileName:="e:\worddocs\Clients.doc")
>> ' Get the number or clients = number of rows in the table of client
>> details less one
>> i = sourcedoc.Tables(1).Rows.Count - 1
>> ' Get the number of columns in the table of client details
>> j = sourcedoc.Tables(1).Columns.Count
>> ' Set the number of columns in the Listbox to match
>> ' the number of columns in the table of client details
>> ListBox1.ColumnCount = j
>> ' Define an array to be loaded with the client data
>> Dim MyArray() As Variant
>> 'Load client data into MyArray
>> ReDim MyArray(i, j)
>> For n = 0 To j - 1
>> For m = 0 To i - 1
>> Set myitem = sourcedoc.Tables(1).Cell(m + 2, n + 1).Range
>> myitem.End = myitem.End - 1
>> MyArray(m, n) = myitem.Text
>> Next m
>> Next n
>> ' Load data into ListBox1
>> ListBox1.List() = MyArray
>> ' Close the file containing the client details
>> sourcedoc.Close SaveChanges:=wdDoNotSaveChanges
>> End Sub
>>
>> Private Sub CommandButton1_Click()
>> Dim i As Integer, Addressee As String
>> Addressee = ""
>> For i = 1 To ListBox1.ColumnCount
>> ListBox1.BoundColumn = i
>> Addressee = Addressee & ListBox1.Value & vbCr
>> Next i
>> ActiveDocument.Bookmarks("Addressee").Range.InsertAfter Addressee
>> UserForm2.Hide
>> End Sub
>>
>> The Initialize statement will populate the listbox with the data from the
>> table and then when a client is selected in from the list and the command
>> button is clicked, the information for that client will be inserted into
>> a
>> bookmark in the document. You may want to vary the manner in which it is
>> inserted to suit our exact requirements, but hopefully this will get you
>> started.
>>
>> To make it easy for you, the code has been written so that it will deal
>> with
>> any number of clients and any number of details about each client. It
>> assumes that the first row of the table containing the client details is
>> a
>> header row.
>>
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
>> news:27C327BA-46A8-45EE-B913-A984423393DA[ at ]microsoft.com...
>> > Basically this is what i want to do.
>> > I am trying to create a drop down menu in MS Word 2003, which will
>> > display
>> > a
>> > list of names [ i am using these names as the signature of the
>> > document,
>> > which means if a letter has been written by Mr.Smith, by using the drop
>> > down
>> > menu i should be able to select Mr.Smith, and Mr.Smith`s e-sign should
>> > be
>> > loaded at the last page of the document]. I do not know how to do this,
>> > but
>> > had i guess that the add-in will be a good way to do it. If there is
>> > any
>> > other way of doing it, kindly tell me.
>> > Hope you understood what i am trying to say.
>> >
>> >
>> > "Doug Robbins - Word MVP" wrote:
>> >
>> >> To create an add in, you save a template in the Word Startup folder,
>> >> the
>> >> location of which you can determine via Tools>Options>File Locations.
>> >>
>> >> To find out about adding toolbars, see the article "How to assign a
>> >> Word
>> >> command or macro to a toolbar or menu" at:
>> >>
>> >> http://www.word.mvps.org/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm
>> >>
>> >> and take a look at some of the other articles on that site to do with
>> >> toolbars.
>> >>
>> >> --
>> >> Hope this helps.
>> >>
>> >> Please reply to the newsgroup unless you wish to avail yourself of my
>> >> services on a paid consulting basis.
>> >>
>> >> Doug Robbins - Word MVP
>> >>
>> >> "Zaid Papa" <Zaid Papa[ at ]discussions.microsoft.com> wrote in message
>> >> news:894F55BC-22DF-4AB3-AEA9-85CC8B23B6E1[ at ]microsoft.com...
>> >> > Hi,
>> >> > I want to create a MS Word Add in which should contain a dropdown
>> >> > menu.
>> >> > I
>> >> > googled for some time to learn how to create a word add- in as i
>> >> > have
>> >> > never
>> >> > done this before. But i could not find a proper article which
>> >> > explains
>> >> > exactly how to create a add-in. Hence can anybody help me in this!
>> >> > Thanks
>> >> > Zaid Papa
>> >>
>> >>
>> >>
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net