Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

Problem searching for text in a range

 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word programming
View previous topic :: View next topic  
Author Message
server
Guest





PostPosted: Sun Apr 22, 2007 5:35 pm    Post subject: Problem searching for text in a range Reply with quote

message unavailable
Back to top
Google
Sponsor





PostPosted: Sun Apr 22, 2007 5:35 pm    Post subject: Advertisement

Back to top
Klaus Linke
Guest





PostPosted: Sun Apr 22, 2007 5:35 pm    Post subject: Re: Problem searching for text in a range Reply with quote

Hi Simon,

After you Execute, the range is set to the matched text.

You need something like

Dim oRangeOld as Range
Set oRangeOld = p_oRange.Duplicate

Do While Not l_bFinished
p_oRange.Find.Execute vbCr, Forward:=True
If p_oRange.Find.Found Then
' ...
p_oRange.Collapse(wdCollapseEnd)
p_oRange.End=oRangeOld.End
Else
l_bFinished = True
End If
Loop

Or, since Execute returns True if some match was found, you could do without
l_bFinished, and re-write the code to something like "Do While .Execute(...)
Loop"

Regards,
Klaus
Back to top
Simon Woods
Guest





PostPosted: Mon Apr 23, 2007 6:03 am    Post subject: Re: Problem searching for text in a range Reply with quote

Klaus Linke wrote:
Quote:
Hi Simon,

After you Execute, the range is set to the matched text.

You need something like

Dim oRangeOld as Range
Set oRangeOld = p_oRange.Duplicate

Do While Not l_bFinished
p_oRange.Find.Execute vbCr, Forward:=True
If p_oRange.Find.Found Then
' ...
p_oRange.Collapse(wdCollapseEnd)
p_oRange.End=oRangeOld.End
Else
l_bFinished = True
End If
Loop

Or, since Execute returns True if some match was found, you could do
without l_bFinished, and re-write the code to something like "Do
While .Execute(...) Loop"

Regards,
Klaus

Excellent ... thanks Klaus
Back to top
Pat Garard
Guest





PostPosted: Wed Apr 25, 2007 8:00 am    Post subject: Re: save as feature Reply with quote

G'Day Helen,

When editing a document called (say) 'Example.doc', Word creates one or
more temporary files for its own purposes.

These may have names like '~$ample.doc' (usually in the same folder as
'Example.doc') and 'AutoRecovery save of Example.asd' (in the
AutoRecover folder).

Following a successful Close of the Document, these should be deleted by
Word - but sometimes they are not.

You seem to be using one of these files for YOUR purposes - and confusing
Word into the bargain.

You should probably 'clean up' any files of this kind that you find - i.e.
delete
them OR if they seem to be valuable then rename them.
--
Regards,
Pat Garard
Melbourne, Australia
_______________________

"Helen" <Helen@discussions.microsoft.com> wrote in message
news:26111C58-5FE2-42A4-BF74-510D51FC092A@microsoft.com...
Quote:
When I'm using Word and I'm using an old letter and then try to use "save
as", my whole screen freezes. I then have to shut down and start all over
again. I noticed when "save as" first comes up the file I was using has '~$
right in front of my file. That seems to be when my screen freezes. It only
does this 50% of the time. The rest of the time its OK. If I shut down the
computer completely and bring word back up. It's fine. Please help. Helen
Back to top
Guest






PostPosted: Wed May 30, 2007 2:03 pm    Post subject: Command button problem Reply with quote

Hi Jason,
I was looking earlier today at this site for a solution to a very similar problem but unluckily there was no answer to your question.
My problem was that in the protected Word form document I was changing the content of the header and footer and after that when trying to re-protect a document back I was getting the same error "The ToolsProtectDocument statement is currently
disabled". After some time I realised I had to select any form cell in the main document body before trying to protect the document again and this has worked. Here it is, the two liner I am talking about :
....
ActiveDocument.FormFields(1).Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
....

If not too late, I hope this will help you or maybe somebody else.

Cheers
Darko


EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Back to top
CJ
Guest





PostPosted: Wed Jul 11, 2007 11:17 pm    Post subject: Word Form - Disable printing of non-enabled checkbox fields Reply with quote

I am reposting this request to this forum. I apparently posted to wrong
forum and never received another response where to re-post. Please read
from bottom up for full understanding. Thanks in advance for any
assistance.
-CJ

"CJ" <LonestarCJ@nospam.com> wrote in message
news:uVwmGt9wHHA.600@TK2MSFTNGP05.phx.gbl...
Quote:
Thanks Russ for your prompt response. Can you direct me to the correct
user group? I was not aware that a userform is not a form utilizing form
fields or control toolbox. I also understand your response below on
hiding text (and am aware of how to do that) however, I am not the one
that will be choosing which options to print and which ones not to print.
I'm a legal assistant and I am trying to create a legal addendum to a
contract for use in the field. In as simple terms as I can, I'll give the
example below of a form I'm trying to create.
------------------------------------------------------------------------|
ADDENDUM
Preamble Text - This addendum is between Us and Customer and modifies the
contract as follows:

[checkbox1] Section X is hereby modified to blah blah
[checkbox2] Section N is hereby modified to blah blah
[checkbox3] Section Y is hereby modified to blah blah

Closing terms of agreement and signatures.
------------------------------------------------------------------------|

Now if the user selects the first option and the third option, is there a
way to have the second option not print? Or if they only choose one of
the amended options, is there a way to not have the other options print?
They should have the ability to choose any (or all) the options that apply
to their specific customer. I also tried a listbox which I could almost
get to work however, several of the options are 300 characters in length
and don't fit in a listbox.

Thanks again!
-CJ
________________________________________________________________________________________________

"Russ" <drsN0SPAMmikle@hotmailD0Tcom.INVALID> wrote in message
news:C2BA7AB8.1AEFE%drsN0SPAMmikle@hotmailD0Tcom.INVALID...
CJ,
I think you are talking about formfields in a document and not userform
dialogs. One way to not print something without a gap in a document is to
create bookmarks for those areas and make all text font and paragraph
marks
between the text in those bookmarked areas hidden. As long as an option
in
Word to print hidden text is not check, which it isn't by default, then
the
gaps should close. It's up to you to design the document in a way that it
still looks good with those areas hidden. You may have to temporarily
unprotect the document, if we are talking about a document with
formfiels,
to make those bookmarked areas hidden. When you go into Print Preview
mode
you should see how the document will look when printed.

__________________________________________________________________________________________________

Quote:
I have a form designed with a list of five items with a checkbox beside
each
item. I need the ability for the end user to choose any or all of the
five
checkboxes however, if they only choose the first and the fourth items
listed on the checkbox list, I do not want the second, third, or fifth
item
to print. Is there a way to get the form to NOT print those items not
enabled (checkmarked)? If so, albeit not as important, is there a way
to
then close the gap of white space left when those items do not print?
(If requested, I can send a Word file sample of the document I am trying
to do this with.)

Thank you for any assistance you can offer. (Running Windows XP, Office
2003 SP2)
-CJ
Back to top
Doug Robbins - Word MVP
Guest





PostPosted: Thu Jul 12, 2007 2:54 am    Post subject: Re: Word Form - Disable printing of non-enabled checkbox fie Reply with quote

See response to your original post in the UserForms newsgroup.

--
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

"CJ" <LonestarCJ@nospam.com> wrote in message
news:uLDxEGBxHHA.1776@TK2MSFTNGP03.phx.gbl...
Quote:
I am reposting this request to this forum. I apparently posted to wrong
forum and never received another response where to re-post. Please read
from bottom up for full understanding. Thanks in advance for any
assistance.
-CJ

"CJ" <LonestarCJ@nospam.com> wrote in message
news:uVwmGt9wHHA.600@TK2MSFTNGP05.phx.gbl...
Thanks Russ for your prompt response. Can you direct me to the correct
user group? I was not aware that a userform is not a form utilizing form
fields or control toolbox. I also understand your response below on
hiding text (and am aware of how to do that) however, I am not the one
that will be choosing which options to print and which ones not to print.
I'm a legal assistant and I am trying to create a legal addendum to a
contract for use in the field. In as simple terms as I can, I'll give
the example below of a form I'm trying to create.
------------------------------------------------------------------------|
ADDENDUM
Preamble Text - This addendum is between Us and Customer and modifies the
contract as follows:

[checkbox1] Section X is hereby modified to blah blah
[checkbox2] Section N is hereby modified to blah blah
[checkbox3] Section Y is hereby modified to blah blah

Closing terms of agreement and signatures.
------------------------------------------------------------------------|

Now if the user selects the first option and the third option, is there a
way to have the second option not print? Or if they only choose one of
the amended options, is there a way to not have the other options print?
They should have the ability to choose any (or all) the options that
apply to their specific customer. I also tried a listbox which I could
almost get to work however, several of the options are 300 characters in
length and don't fit in a listbox.

Thanks again!
-CJ
________________________________________________________________________________________________

"Russ" <drsN0SPAMmikle@hotmailD0Tcom.INVALID> wrote in message
news:C2BA7AB8.1AEFE%drsN0SPAMmikle@hotmailD0Tcom.INVALID...
CJ,
I think you are talking about formfields in a document and not userform
dialogs. One way to not print something without a gap in a document is
to
create bookmarks for those areas and make all text font and paragraph
marks
between the text in those bookmarked areas hidden. As long as an option
in
Word to print hidden text is not check, which it isn't by default, then
the
gaps should close. It's up to you to design the document in a way that
it
still looks good with those areas hidden. You may have to temporarily
unprotect the document, if we are talking about a document with
formfiels,
to make those bookmarked areas hidden. When you go into Print Preview
mode
you should see how the document will look when printed.

__________________________________________________________________________________________________

I have a form designed with a list of five items with a checkbox beside
each
item. I need the ability for the end user to choose any or all of the
five
checkboxes however, if they only choose the first and the fourth items
listed on the checkbox list, I do not want the second, third, or fifth
item
to print. Is there a way to get the form to NOT print those items not
enabled (checkmarked)? If so, albeit not as important, is there a way
to
then close the gap of white space left when those items do not print?
(If requested, I can send a Word file sample of the document I am
trying to do this with.)

Thank you for any assistance you can offer. (Running Windows XP,
Office
2003 SP2)
-CJ

Back to top
Klaus Linke
Guest





PostPosted: Thu Oct 25, 2007 7:51 pm    Post subject: Re: Unformatted Paste Reply with quote

Hi Chris,

Word 2007 also has very nice options to set the paste options, depending on
whether you cut/copy/paste inside a doc, between docs (with the same or
different styles), or from another program.
(Office button > Word options > Advanced > Cut, copy and paste... or
something like that)

I really like those new options settings ... A macro for pasting unformatted
is still good to have in the toolbox, though :-)

Regards,
Klaus
Back to top
ParanoidMike
Guest





PostPosted: Thu Nov 01, 2007 8:10 pm    Post subject: Why aren't my Toolbar buttons doing anything? [was CommandBa Reply with quote

I haven't had any response so far - perhaps a more attention-getting
Subject will help? If anyone has any suggestions on what I should try
to modify in my VSTO code, to get these toolbar buttons to actually
run the code I've tried to connect to them, I'd sure appreciate the
help.

e.g. even though I've declared each CommandBarButton using the
"WithEvents" keyword *and* I've included an Event Handler subroutine
for the button's Click event, is it necessary to actually Add the
button each time the Add-in runs?

I notice that I've coded this Add-in in a way that it only Adds the
button if it doesn't currently exist (marked with *** below), so that
after the first time I launch Word, it should never add the button
again. However, I had assumed that once the button (with its Event
Handler) was created the first time, the Event Handlers would fire on
their own without any additional Startup activity for the Add-in. Is
this a false assumption?

Thanks, Mike

On Oct 30, 9:01 am, ParanoidMike <mikesmithloner...@gmail.com> wrote:
Quote:
I *cannot* figure out what I'm missing to get my Event Handlers to
fire when I click the buttons I've added to a VSTO toolbar
(application add-in) in Word. The code approach I've used is
patterned after a working CommandBar & CommandBarButtons I have in a
different project, and it mirrors the approach documented in "VSTO for
Mere Mortals".

Here's the setup:
- Word 2003 SP3
- Visual Studio 2005 with the VSTO and VSTO SE add-ons
- Office PIAs and other dependencies installed (since other VSTO
projects work correctly in this copy of Word)
- I've even double-checked that the CAS policy that Visual Studio
automatically configures is "correctly" allowing FullTrust to my
assemblies (via the default URL policy that VS generates)

Here's the relevant code snipped from the current project (note that
the Structure is used to simplify the setup for three similar
CommandBarButtons, but I've only shown one button here):

Private W2MWPPBar As Office.CommandBar
Private WithEvents uiConvert As Office.CommandBarButton

Structure CommandBarButtonSettings
Public BeginGroupProperty As Boolean
Public ButtonVariable As Office.CommandBarButton
Public CaptionProperty As String
Public DescriptionTextProperty As String
Public FaceIDProperty As Integer
Public StyleProperty As Office.MsoButtonStyle
Public Tag As String
Public TooltipTextProperty As String
End Structure


Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup

Dim commandBarsCollection As Office.CommandBars =
DirectCast(Application.CommandBars, Office.CommandBars)

If commandBarsCollection.FindControl(Tag:=TOOLBAR_NAME) Is
Nothing Then
W2MWPPBar = commandBarsCollection.Add(TOOLBAR_NAME, _

Office.MsoBarPosition.msoBarTop, _
False, _
True)
Else
W2MWPPBar = Application.CommandBars(TOOLBAR_NAME)
End If

Dim buttonSettings As New CommandBarButtonSettings()
Dim buttonsList As New ArrayList()

buttonSettings.ButtonVariable = uiConvert
buttonSettings.CaptionProperty = "Convert to Wiki"
buttonSettings.DescriptionTextProperty = "Converts Word
Documents to MediaWiki format."
buttonSettings.FaceIDProperty = 2144
buttonSettings.StyleProperty =
Office.MsoButtonStyle.msoButtonIconAndCaption
buttonSettings.Tag = "W2MWPP Convert"
buttonSettings.TooltipTextProperty = "Word2MediaWiki++ -
Convert to MediaWiki syntax"

buttonsList.Add(buttonSettings)


For Each _buttonSettings As CommandBarButtonSettings In
buttonsList


***
Quote:
If W2MWPPBar.FindControl(Tag:=_buttonSettings.Tag) Is
Nothing Then
buttonSettings.ButtonVariable =
CType(W2MWPPBar.Controls.Add(1), _

Office.CommandBarButton)
***


Quote:
Else
buttonSettings.ButtonVariable =
W2MWPPBar.FindControl(Tag:=_buttonSettings.Tag)
End If

With buttonSettings.ButtonVariable
.Caption = _buttonSettings.CaptionProperty
.DescriptionText =
_buttonSettings.DescriptionTextProperty
.FaceId = _buttonSettings.FaceIDProperty
.Style = _buttonSettings.StyleProperty
.Tag = _buttonSettings.Tag
.TooltipText = _buttonSettings.TooltipTextProperty
End With
End Sub

Private Sub uiConvert_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As
Boolean) Handles uiConvert.Click
' Event Handler code goes here...
End Sub

If you're interested in reviewing the source code in its entirety,
you're welcome to take a look at it here:http://www.codeplex.com/word2mediawikipp/SourceControl/DirectoryView....

So: with all this code in place, does anyone have any idea why the
CommandBar buttons do *nothing* when I click on them? [I've set
breakpoints in the code at the beginning of the Event Handlers, and VS
never breaks, so I'm 99% sure the handlers never get called. However,
when I had .OnAction properties being set for each CommandBarButton, I
was getting the VBA macro errors that are called out in Cindy
Meister's responses here:http://groups.google.com/group/microsoft.public.office.developer.com....]

Thanks for any assistance anyone can provide,
Mike
Back to top
Chris Boorman
Guest





PostPosted: Wed Nov 07, 2007 9:57 pm    Post subject: Re: Unformatted Paste Reply with quote

I'm aware of Word 2007's new paste options, but I've found that they are
unsuitabled to my needs.

"Klaus Linke" <info@fotosatz-kaufmann.de> wrote in message
news:%23xqA0B0FIHA.5272@TK2MSFTNGP05.phx.gbl...
Quote:
Hi Chris,

Word 2007 also has very nice options to set the paste options, depending
on whether you cut/copy/paste inside a doc, between docs (with the same or
different styles), or from another program.
(Office button > Word options > Advanced > Cut, copy and paste... or
something like that)

I really like those new options settings ... A macro for pasting
unformatted is still good to have in the toolbox, though :-)

Regards,
Klaus
Back to top
Swapnil Shejul
Guest





PostPosted: Mon Dec 10, 2007 1:30 pm    Post subject: RE: Why aren't my Toolbar buttons doing anything? [was Comma Reply with quote

Hi Mike,

Well ! I am not expert in this field and writing some of my early Plugins
using VSTO.
But I came across exactly same problem as yours !

I guess u will have to make the declaration of commandbar variable at class
level.To simplyfy the process I will paste my code (this was written for a
OUTLOOK plugin) but i guess it is not a big deal to convert it for WORD.

'-------------------------CODE SNIPPET STARTS----------------------
Public Partial Class ThisAddIn
Private Const MENU_BEFORE As String = "Help"
Private menuBar As Office.CommandBar
Private helpMenuIndex As Object
Private topMenu As Office.CommandBarPopup
Private MenuItem1 As Office.CommandBarButton
Private BankMenuItem1 As Office.CommandBarButton
Private BankMenuItem2 As Office.CommandBarButton

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As
System.EventArgs)

If MessageBox.Show("Do u want to proceed for plugin?",
"Plugin-startup message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
DialogResult.Yes Then
Me.InitializeMenu()
Me.AttachEventHandler()
End If
End Sub
Private Sub InitializeMenu()
'Get the Active menu bar
menuBar = Me.Application.ActiveExplorer().CommandBars.ActiveMenuBar

' Get the index of the Help menu on the Outlook menu bar.
Try
helpMenuIndex = menuBar.Controls(MENU_BEFORE).Index
Catch ex As Exception
helpMenuIndex = menuBar.Controls.Count
End Try
' Add the top-level menu right before the Help menu.
topMenu =
DirectCast(menuBar.Controls.Add(Office.MsoControlType.msoControlPopup,
Type.Missing, Type.Missing, helpMenuIndex, True), Office.CommandBarPopup)
topMenu.Caption = "Test Menu"
topMenu.Visible = True
'--------Add FIRST sub-item to "Bank
Menu"-------------------------------
BankMenuItem1 =
DirectCast(topMenu.Controls.Add(Office.MsoControlType.msoControlButton,
Type.Missing, Type.Missing, 1, True), Office.CommandBarButton)
BankMenuItem1.Caption = "TestButton1"
BankMenuItem1.Visible = True
'--------Add SECOND sub-item to "Bank
Menu"-------------------------------
BankMenuItem2 =
DirectCast(topMenu.Controls.Add(Office.MsoControlType.msoControlButton,
Type.Missing, Type.Missing, 2, True), Office.CommandBarButton)
BankMenuItem2.Caption = "TestButton2"
BankMenuItem2.Visible = True
'------Add button DIRECTLY to the topmost level in the outlook
menubar----------------/
MenuItem1 =
DirectCast(menuBar.Controls.Add(Office.MsoControlType.msoControlButton,
Type.Missing, Type.Missing, 1, True), Office.CommandBarButton)
MenuItem1.Caption = "ATM-List"
MenuItem1.Visible = True
End Sub
Private Sub MenuItem_Click(ByVal cmdBarbutton As
Office.CommandBarButton, ByRef cancel As Boolean)
If MessageBox.Show("Do u want to send Email?", "Send An E-Mail",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
SendEmail()
End If
End Sub
Private Sub BankMenuItem2_Click(ByVal cmdBarbutton As
Office.CommandBarButton, ByRef cancel As Boolean)
MessageBox.Show("BankMenuItem2 button was clicked",
"Bank-Button2-ClickEvent")
End Sub
Private Sub SendEmail()
' Create a new e-mail item.
Dim mailItem As Outlook.MailItem =
DirectCast(Me.Application.CreateItem(Outlook.OlItemType.olMailItem),
Outlook.MailItem)

' Set the Subject property of the new MailItem.
mailItem.Subject = "Hello World!"

' Set the To address of the new MailItem to the username for the
current session.
'mailItem.To = this.Session.CurrentUser.Name.ToString();
mailItem.[To] = "swapnil.shejul@gmail.com"
' Set the body of the new MailItem.
mailItem.Body = "This is the first Outlook application I " +
"created by using Visual Studio Tools for Office."

' Display the new MailItem.
mailItem.Display(False)

' Show a message box with options to send or not send the e-mail
message.
If MessageBox.Show("Would you like to send your Hello World! e-mail
message?", "HandsOnLab.Lab", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) = DialogResult.Yes Then
' Yes, send this message.
DirectCast(mailItem, Outlook._MailItem).Send()
Else
' Do not send this message. Close the MailItem and discard any
changes.
DirectCast(mailItem,
Outlook._MailItem).Close(Outlook.OlInspectorClose.olDiscard)
End If
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As
System.EventArgs)
End Sub


'--------------------------------------------------------------------------------------------------
Private Sub AttachEventHandler()
AddHandler MenuItem1.Click, AddressOf MenuItem_Click
AddHandler BankMenuItem2.Click, AddressOf BankMenuItem2_Click

'--------------------------------------------------------------------------------------------------------------
End Sub

End Class

'-------------------------CODE SNIPPET ENDS----------------------

Hope this helps you a bit :-)

N'Joy Life N Try Hard,
Swaps


"ParanoidMike" wrote:

Quote:
I haven't had any response so far - perhaps a more attention-getting
Subject will help? If anyone has any suggestions on what I should try
to modify in my VSTO code, to get these toolbar buttons to actually
run the code I've tried to connect to them, I'd sure appreciate the
help.

e.g. even though I've declared each CommandBarButton using the
"WithEvents" keyword *and* I've included an Event Handler subroutine
for the button's Click event, is it necessary to actually Add the
button each time the Add-in runs?

I notice that I've coded this Add-in in a way that it only Adds the
button if it doesn't currently exist (marked with *** below), so that
after the first time I launch Word, it should never add the button
again. However, I had assumed that once the button (with its Event
Handler) was created the first time, the Event Handlers would fire on
their own without any additional Startup activity for the Add-in. Is
this a false assumption?

Thanks, Mike

On Oct 30, 9:01 am, ParanoidMike <mikesmithloner...@gmail.com> wrote:
I *cannot* figure out what I'm missing to get my Event Handlers to
fire when I click the buttons I've added to a VSTO toolbar
(application add-in) in Word. The code approach I've used is
patterned after a working CommandBar & CommandBarButtons I have in a
different project, and it mirrors the approach documented in "VSTO for
Mere Mortals".

Here's the setup:
- Word 2003 SP3
- Visual Studio 2005 with the VSTO and VSTO SE add-ons
- Office PIAs and other dependencies installed (since other VSTO
projects work correctly in this copy of Word)
- I've even double-checked that the CAS policy that Visual Studio
automatically configures is "correctly" allowing FullTrust to my
assemblies (via the default URL policy that VS generates)

Here's the relevant code snipped from the current project (note that
the Structure is used to simplify the setup for three similar
CommandBarButtons, but I've only shown one button here):

Private W2MWPPBar As Office.CommandBar
Private WithEvents uiConvert As Office.CommandBarButton

Structure CommandBarButtonSettings
Public BeginGroupProperty As Boolean
Public ButtonVariable As Office.CommandBarButton
Public CaptionProperty As String
Public DescriptionTextProperty As String
Public FaceIDProperty As Integer
Public StyleProperty As Office.MsoButtonStyle
Public Tag As String
Public TooltipTextProperty As String
End Structure


Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup

Dim commandBarsCollection As Office.CommandBars =
DirectCast(Application.CommandBars, Office.CommandBars)

If commandBarsCollection.FindControl(Tag:=TOOLBAR_NAME) Is
Nothing Then
W2MWPPBar = commandBarsCollection.Add(TOOLBAR_NAME, _

Office.MsoBarPosition.msoBarTop, _
False, _
True)
Else
W2MWPPBar = Application.CommandBars(TOOLBAR_NAME)
End If

Dim buttonSettings As New CommandBarButtonSettings()
Dim buttonsList As New ArrayList()

buttonSettings.ButtonVariable = uiConvert
buttonSettings.CaptionProperty = "Convert to Wiki"
buttonSettings.DescriptionTextProperty = "Converts Word
Documents to MediaWiki format."
buttonSettings.FaceIDProperty = 2144
buttonSettings.StyleProperty =
Office.MsoButtonStyle.msoButtonIconAndCaption
buttonSettings.Tag = "W2MWPP Convert"
buttonSettings.TooltipTextProperty = "Word2MediaWiki++ -
Convert to MediaWiki syntax"

buttonsList.Add(buttonSettings)


For Each _buttonSettings As CommandBarButtonSettings In
buttonsList


***
If W2MWPPBar.FindControl(Tag:=_buttonSettings.Tag) Is
Nothing Then
buttonSettings.ButtonVariable =
CType(W2MWPPBar.Controls.Add(1), _

Office.CommandBarButton)
***

Else
buttonSettings.ButtonVariable =
W2MWPPBar.FindControl(Tag:=_buttonSettings.Tag)
End If

With buttonSettings.ButtonVariable
.Caption = _buttonSettings.CaptionProperty
.DescriptionText =
_buttonSettings.DescriptionTextProperty
.FaceId = _buttonSettings.FaceIDProperty
.Style = _buttonSettings.StyleProperty
.Tag = _buttonSettings.Tag
.TooltipText = _buttonSettings.TooltipTextProperty
End With
End Sub

Private Sub uiConvert_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As
Boolean) Handles uiConvert.Click
' Event Handler code goes here...
End Sub

If you're interested in reviewing the source code in its entirety,
you're welcome to take a look at it here:http://www.codeplex.com/word2mediawikipp/SourceControl/DirectoryView....

So: with all this code in place, does anyone have any idea why the
CommandBar buttons do *nothing* when I click on them? [I've set
breakpoints in the code at the beginning of the Event Handlers, and VS
never breaks, so I'm 99% sure the handlers never get called. However,
when I had .OnAction properties being set for each CommandBarButton, I
was getting the VBA macro errors that are called out in Cindy
Meister's responses here:http://groups.google.com/group/microsoft.public.office.developer.com....]

Thanks for any assistance anyone can provide,
Mike

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum