Double-click vs single-click on macro button
Author |
Message |
Freyj #1 / 11
|
 Double-click vs single-click on macro button
I have some macros that do things like copy the line containing the cursor to a new document. I would like to use some of them in a similar way to what Word does with the VBA Controls buttons or the Format Painter button, i.e., when you single-click it, the macro runs once and quits, but when you double-click it, it would stay active until it is turned off again with a single-click, ctrl/Z, Esc or similar actions. Does anyone know how to accomplish this? I have looked through the on-line help and spent many hours in technical bookstores, but not found anything on this subject.
|
Thu, 14 Aug 2003 02:21:45 GMT |
|
 |
Perr #2 / 11
|
 Double-click vs single-click on macro button
Hi Freya, Looking for somthing like this: Dim StopMacro As Boolean Private Sub CommandButton1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) If Not StopMacro Then 'replace msgbox function by your macro ... MsgBox "This was a double click" StopMacro = True Else Cancel = StopMacro End If Exit Sub End Sub Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) StopMacro = Not StopMacro End Sub Krgrds, Perry
Quote: > I have some macros that do things like copy the line containing the > cursor to a new document. I would like to use some of them in a similar > way to what Word does with the VBA Controls buttons or the Format > Painter button, i.e., when you single-click it, the macro runs once and > quits, but when you double-click it, it would stay active until it is > turned off again with a single-click, ctrl/Z, Esc or similar actions. > Does anyone know how to accomplish this? I have looked through the > on-line help and spent many hours in technical bookstores, but not found > anything on this subject.
|
Thu, 14 Aug 2003 09:11:17 GMT |
|
 |
Freyj #3 / 11
|
 Double-click vs single-click on macro button
Yes, that's pretty much the kind of thing I'm trying to do, but I want the macro to be something I can call from a custom toolbar button in the Normal.Dot template with either a single- or double-click, not just from a UserForm. Sorry that I didn't make that clearer in the first place. Format Painter has exactly the kind of behavior I'm trying to copy, except that I want to do different things than copy a format. The particular function I'm trying to achieve at the moment is this: I have written a macro that grabs the line currently containing the cursor and copies it to the end of the 'other' document currently open. The macro works fine - it has all the necessary poop for checking that there are no more than two documents currently open, if there is only one it creates the second one, and so on. The user has a sort of 'master' document from which she creates a second, abbreviated one by selecting only the appropriate lines for the current situation. The master itself can change occasionally, and she does that with normal Word processing, so I can't create a custom form from which she would just check boxes - it would require my intervention every time the master changed. I can speed things up for her by adding a keyboard shortcut to the macro, but the ideal situation would be to be able to either run the macro once to grab a praticular line, OR, double-click to turn the macro on continuously, so that it would grab a line every time the user clicked in one, and would continue to do that until it was turned off again. Quote:
> Hi Freya, > Looking for somthing like this: > Dim StopMacro As Boolean > Private Sub CommandButton1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) > If Not StopMacro Then > 'replace msgbox function by your macro ... > MsgBox "This was a double click" > StopMacro = True > Else > Cancel = StopMacro > End If > Exit Sub > End Sub > Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As > Integer, ByVal X As Single, ByVal Y As Single) > StopMacro = Not StopMacro > End Sub > Krgrds, > Perry
> > I have some macros that do things like copy the line containing the > > cursor to a new document. I would like to use some of them in a similar > > way to what Word does with the VBA Controls buttons or the Format > > Painter button, i.e., when you single-click it, the macro runs once and > > quits, but when you double-click it, it would stay active until it is > > turned off again with a single-click, ctrl/Z, Esc or similar actions. > > Does anyone know how to accomplish this? I have looked through the > > on-line help and spent many hours in technical bookstores, but not found > > anything on this subject.
|
Thu, 14 Aug 2003 12:21:06 GMT |
|
 |
Perr #4 / 11
|
 Double-click vs single-click on macro button
Hi Freya, You will need to adapt the below example to copy the selection.range.text to the other document ... Add a UserForm in a project, draw two commandbuttons and a listbox. Commandbutton1 rename to: btnBack Commandbutton1 rename to: btnForward ListBox1 rename to: lstSelectionText Look at below code and how it acts when running the form: Private Sub btnBack_Click() With ActiveDocument .Paragraphs(GetParagrNum - 1).Range.Select btnBack.Enabled = Not (GetParagrNum = 1) btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) End With lstSelectionText = Selection.Range.Text End Sub Private Sub btnForward_Click() With ActiveDocument .Paragraphs(GetParagrNum + 1).Range.Select btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) btnBack.Enabled = Not (GetParagrNum = 1) End With lstSelectionText = Selection.Range.Text End Sub Private Sub UserForm_Initialize() ActiveDocument.Paragraphs(1).Range.Select End Sub Private Function GetParagrNum() As Long GetParagrNum = Selection.Range.Information(wdFirstCharacterLineNumber) End Function Krgrds, Perry
Quote: > Yes, that's pretty much the kind of thing I'm trying to do, but I want > the macro to be something I can call from a custom toolbar button in the > Normal.Dot template with either a single- or double-click, not just from > a UserForm. Sorry that I didn't make that clearer in the first place. > Format Painter has exactly the kind of behavior I'm trying to copy, > except that I want to do different things than copy a format. The > particular function I'm trying to achieve at the moment is this: > I have written a macro that grabs the line currently containing the > cursor and copies it to the end of the 'other' document currently open. > The macro works fine - it has all the necessary poop for checking that > there are no more than two documents currently open, if there is only > one it creates the second one, and so on. The user has a sort of > 'master' document from which she creates a second, abbreviated one by > selecting only the appropriate lines for the current situation. The > master itself can change occasionally, and she does that with normal > Word processing, so I can't create a custom form from which she would > just check boxes - it would require my intervention every time the > master changed. > I can speed things up for her by adding a keyboard shortcut to the > macro, but the ideal situation would be to be able to either run the > macro once to grab a praticular line, OR, double-click to turn the macro > on continuously, so that it would grab a line every time the user > clicked in one, and would continue to do that until it was turned off > again.
> > Hi Freya, > > Looking for somthing like this: > > Dim StopMacro As Boolean > > Private Sub CommandButton1_DblClick(ByVal Cancel As
MSForms.ReturnBoolean) Quote: > > If Not StopMacro Then > > 'replace msgbox function by your macro ... > > MsgBox "This was a double click" > > StopMacro = True > > Else > > Cancel = StopMacro > > End If > > Exit Sub > > End Sub > > Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As > > Integer, ByVal X As Single, ByVal Y As Single) > > StopMacro = Not StopMacro > > End Sub > > Krgrds, > > Perry
> > > I have some macros that do things like copy the line containing the > > > cursor to a new document. I would like to use some of them in a similar > > > way to what Word does with the VBA Controls buttons or the Format > > > Painter button, i.e., when you single-click it, the macro runs once and > > > quits, but when you double-click it, it would stay active until it is > > > turned off again with a single-click, ctrl/Z, Esc or similar actions. > > > Does anyone know how to accomplish this? I have looked through the > > > on-line help and spent many hours in technical bookstores, but not found > > > anything on this subject.
|
Thu, 14 Aug 2003 16:59:43 GMT |
|
 |
Freyj #5 / 11
|
 Double-click vs single-click on macro button
Thank you, Perry, your code does a nice job, but that's not my problem. My code already does the selection and copying just fine. Are you familiar with the Format Painter button? If not, it's the small paintbrush next to the Cut/Copy/Paste buttons on the Standard toolbar. When you single-click it, it copies the format of the text currently under the cursor into a hold buffer somewhere and the paintbrush button is depressed. You then select some more text and it immediately formats that newly selected text to the same format as where the cursor was when the button was first clicked, and the paintbrush button is released. When you do the same thing, but double-click instead of single-click, the effect is the same, except that the button STAYS depressed, and every bit of text selected after that is formatted immediately upon selection. This continues until the button is released by single-clicking it again, pressing ctrl/Z or pressing ESC. There are probably other ways to release it as well, but those are the three I use. Anyway, THAT'S the effect I'm after - a macro that either runs once when I single-click its button on the toolbar, or runs 'continuously' in the background, pouncing on any line I select until it is turned off again. Does this make any more sense? Quote:
> Hi Freya, > You will need to adapt the below example to copy the selection.range.text > to the other document ... > Add a UserForm in a project, draw two commandbuttons > and a listbox. > Commandbutton1 rename to: btnBack > Commandbutton1 rename to: btnForward > ListBox1 rename to: lstSelectionText > Look at below code and how it acts when running the form: > Private Sub btnBack_Click() > With ActiveDocument > .Paragraphs(GetParagrNum - 1).Range.Select > btnBack.Enabled = Not (GetParagrNum = 1) > btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) > End With > lstSelectionText = Selection.Range.Text > End Sub > Private Sub btnForward_Click() > With ActiveDocument > .Paragraphs(GetParagrNum + 1).Range.Select > btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) > btnBack.Enabled = Not (GetParagrNum = 1) > End With > lstSelectionText = Selection.Range.Text > End Sub > Private Sub UserForm_Initialize() > ActiveDocument.Paragraphs(1).Range.Select > End Sub > Private Function GetParagrNum() As Long > GetParagrNum = Selection.Range.Information(wdFirstCharacterLineNumber) > End Function > Krgrds, > Perry
> > Yes, that's pretty much the kind of thing I'm trying to do, but I want > > the macro to be something I can call from a custom toolbar button in the > > Normal.Dot template with either a single- or double-click, not just from > > a UserForm. Sorry that I didn't make that clearer in the first place. > > Format Painter has exactly the kind of behavior I'm trying to copy, > > except that I want to do different things than copy a format. The > > particular function I'm trying to achieve at the moment is this: > > I have written a macro that grabs the line currently containing the > > cursor and copies it to the end of the 'other' document currently open. > > The macro works fine - it has all the necessary poop for checking that > > there are no more than two documents currently open, if there is only > > one it creates the second one, and so on. The user has a sort of > > 'master' document from which she creates a second, abbreviated one by > > selecting only the appropriate lines for the current situation. The > > master itself can change occasionally, and she does that with normal > > Word processing, so I can't create a custom form from which she would > > just check boxes - it would require my intervention every time the > > master changed. > > I can speed things up for her by adding a keyboard shortcut to the > > macro, but the ideal situation would be to be able to either run the > > macro once to grab a praticular line, OR, double-click to turn the macro > > on continuously, so that it would grab a line every time the user > > clicked in one, and would continue to do that until it was turned off > > again.
> > > Hi Freya, > > > Looking for somthing like this: > > > Dim StopMacro As Boolean > > > Private Sub CommandButton1_DblClick(ByVal Cancel As > MSForms.ReturnBoolean) > > > If Not StopMacro Then > > > 'replace msgbox function by your macro ... > > > MsgBox "This was a double click" > > > StopMacro = True > > > Else > > > Cancel = StopMacro > > > End If > > > Exit Sub > > > End Sub > > > Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal > Shift As > > > Integer, ByVal X As Single, ByVal Y As Single) > > > StopMacro = Not StopMacro > > > End Sub > > > Krgrds, > > > Perry
> > > > I have some macros that do things like copy the line containing the > > > > cursor to a new document. I would like to use some of them in a > similar > > > > way to what Word does with the VBA Controls buttons or the Format > > > > Painter button, i.e., when you single-click it, the macro runs once > and > > > > quits, but when you double-click it, it would stay active until it is > > > > turned off again with a single-click, ctrl/Z, Esc or similar actions. > > > > Does anyone know how to accomplish this? I have looked through the > > > > on-line help and spent many hours in technical bookstores, but not > found > > > > anything on this subject.
|
Fri, 15 Aug 2003 05:01:01 GMT |
|
 |
Perr #6 / 11
|
 Double-click vs single-click on macro button
Hi Freya, Quote: > familiar with the Format Painter button? If not, it's the small
Hmm, never used this ... I had to found how it worked ... As to copying it's behaviour you could use ... Have you tried playing around with application events more specifically, the WindowSelectionChange? If not: www.mvps.org Look up the topic on Application Events Krgrds, Perry
Quote: > Thank you, Perry, your code does a nice job, but that's not my problem. > My code already does the selection and copying just fine. Are you > familiar with the Format Painter button? If not, it's the small > paintbrush next to the Cut/Copy/Paste buttons on the Standard toolbar. > When you single-click it, it copies the format of the text currently > under the cursor into a hold buffer somewhere and the paintbrush button > is depressed. You then select some more text and it immediately formats > that newly selected text to the same format as where the cursor was when > the button was first clicked, and the paintbrush button is released. > When you do the same thing, but double-click instead of single-click, > the effect is the same, except that the button STAYS depressed, and > every bit of text selected after that is formatted immediately upon > selection. This continues until the button is released by > single-clicking it again, pressing ctrl/Z or pressing ESC. There are > probably other ways to release it as well, but those are the three I > use. Anyway, THAT'S the effect I'm after - a macro that either runs once > when I single-click its button on the toolbar, or runs 'continuously' in > the background, pouncing on any line I select until it is turned off > again. > Does this make any more sense?
> > Hi Freya, > > You will need to adapt the below example to copy the
selection.range.text Quote: > > to the other document ... > > Add a UserForm in a project, draw two commandbuttons > > and a listbox. > > Commandbutton1 rename to: btnBack > > Commandbutton1 rename to: btnForward > > ListBox1 rename to: lstSelectionText > > Look at below code and how it acts when running the form: > > Private Sub btnBack_Click() > > With ActiveDocument > > .Paragraphs(GetParagrNum - 1).Range.Select > > btnBack.Enabled = Not (GetParagrNum = 1) > > btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) > > End With > > lstSelectionText = Selection.Range.Text > > End Sub > > Private Sub btnForward_Click() > > With ActiveDocument > > .Paragraphs(GetParagrNum + 1).Range.Select > > btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) > > btnBack.Enabled = Not (GetParagrNum = 1) > > End With > > lstSelectionText = Selection.Range.Text > > End Sub > > Private Sub UserForm_Initialize() > > ActiveDocument.Paragraphs(1).Range.Select > > End Sub > > Private Function GetParagrNum() As Long > > GetParagrNum =
Selection.Range.Information(wdFirstCharacterLineNumber) Quote: > > End Function > > Krgrds, > > Perry
> > > Yes, that's pretty much the kind of thing I'm trying to do, but I want > > > the macro to be something I can call from a custom toolbar button in the > > > Normal.Dot template with either a single- or double-click, not just from > > > a UserForm. Sorry that I didn't make that clearer in the first place. > > > Format Painter has exactly the kind of behavior I'm trying to copy, > > > except that I want to do different things than copy a format. The > > > particular function I'm trying to achieve at the moment is this: > > > I have written a macro that grabs the line currently containing the > > > cursor and copies it to the end of the 'other' document currently open. > > > The macro works fine - it has all the necessary poop for checking that > > > there are no more than two documents currently open, if there is only > > > one it creates the second one, and so on. The user has a sort of > > > 'master' document from which she creates a second, abbreviated one by > > > selecting only the appropriate lines for the current situation. The > > > master itself can change occasionally, and she does that with normal > > > Word processing, so I can't create a custom form from which she would > > > just check boxes - it would require my intervention every time the > > > master changed. > > > I can speed things up for her by adding a keyboard shortcut to the > > > macro, but the ideal situation would be to be able to either run the > > > macro once to grab a praticular line, OR, double-click to turn the macro > > > on continuously, so that it would grab a line every time the user > > > clicked in one, and would continue to do that until it was turned off > > > again.
> > > > Hi Freya, > > > > Looking for somthing like this: > > > > Dim StopMacro As Boolean > > > > Private Sub CommandButton1_DblClick(ByVal Cancel As > > MSForms.ReturnBoolean) > > > > If Not StopMacro Then > > > > 'replace msgbox function by your macro ... > > > > MsgBox "This was a double click" > > > > StopMacro = True > > > > Else > > > > Cancel = StopMacro > > > > End If > > > > Exit Sub > > > > End Sub > > > > Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal > > Shift As > > > > Integer, ByVal X As Single, ByVal Y As Single) > > > > StopMacro = Not StopMacro > > > > End Sub > > > > Krgrds, > > > > Perry
> > > > > I have some macros that do things like copy the line containing the > > > > > cursor to a new document. I would like to use some of them in a > > similar > > > > > way to what Word does with the VBA Controls buttons or the Format > > > > > Painter button, i.e., when you single-click it, the macro runs once > > and > > > > > quits, but when you double-click it, it would stay active until it is > > > > > turned off again with a single-click, ctrl/Z, Esc or similar actions. > > > > > Does anyone know how to accomplish this? I have looked through the > > > > > on-line help and spent many hours in technical bookstores, but not > > found > > > > > anything on this subject.
|
Sat, 16 Aug 2003 02:08:57 GMT |
|
 |
Jon Sequeir #7 / 11
|
 Double-click vs single-click on macro button
Freyja-- I've been doing Word VBA programming pretty intensely for a few years, and I know of no easy way to do this directly. The only types of buttons VBA allows you to create are combos, popups, and regular old normal buttons. But there might be another way to accomplish basically the same thing. You might want to try using a dropdown button offering the different choices, or have the user hold the Shift key when pressing the button for the extended option. There's a great article on faking button popups at: http://msdn.microsoft.com/library/periodic/period99/button.htm If you're dead set on distinguishing between single- and double-clicks on the button, I'm pretty certain you'll have to subclass the toolbar. --Jon Sequeira
Quote: -----Original Message----- I have some macros that do things like copy the line containing the cursor to a new document. I would like to use some of them in a similar way to what Word does with the VBA Controls buttons or the Format Painter button, i.e., when you single-click it, the macro runs once and quits, but when you double-click it, it would stay active until it is turned off again with a single-click, ctrl/Z, Esc or similar actions. Does anyone know how to accomplish this? I have looked through the on-line help and spent many hours in technical bookstores, but not found anything on this subject. .
|
Sat, 16 Aug 2003 07:29:01 GMT |
|
 |
Freyj #8 / 11
|
 Double-click vs single-click on macro button
Thanks, that was an interesting article and I'll give it a try. The biggest reason I wanted to mimic the Format Painter behavior was to try keeping things 'standard', or as much so as possible. Double-clicking one button, holding Shift for another, popups for a third - some of these users have been known to freak when the Energy Saver kills the monitor power, and call IT to check their 'broken' new computer. One woman even spent two weeks carrying floppies with her documents to a neighboring office to print them because her printer was broken. She finally worked up the nerve to call and ask if there was anything we could do. I'm NOT making this up - it was unplugged. Anyway, anything I can do to keep them from getting nervous is a plus. You mentioned 'subclassing the toolbar'. That sounds complicated, but I'd like to look at the possibility, except I don't know anything about it. Any special articles you could point me to dealing with that? Quote:
> Freyja-- > I've been doing Word VBA programming pretty intensely for a few years, and I know > of no easy way to do this directly. The only types of buttons VBA allows you to > create are combos, popups, and regular old normal buttons. But there might be > another way to accomplish basically the same thing. > You might want to try using a dropdown button offering the different choices, or > have the user hold the Shift key when pressing the button for the extended > option. There's a great article on faking button popups at: > http://msdn.microsoft.com/library/periodic/period99/button.htm > If you're dead set on distinguishing between single- and double-clicks on the > button, I'm pretty certain you'll have to subclass the toolbar. > --Jon Sequeira
> -----Original Message----- > I have some macros that do things like copy the line containing the > cursor to a new document. I would like to use some of them in a similar > way to what Word does with the VBA Controls buttons or the Format > Painter button, i.e., when you single-click it, the macro runs once and > quits, but when you double-click it, it would stay active until it is > turned off again with a single-click, ctrl/Z, Esc or similar actions. > Does anyone know how to accomplish this? I have looked through the > on-line help and spent many hours in technical bookstores, but not found > anything on this subject. > .
|
Sun, 17 Aug 2003 14:51:39 GMT |
|
 |
Freyj #9 / 11
|
 Double-click vs single-click on macro button
No, I just looked that up in Word Help just now, and it looks kind of promising, but it's getting late and I'm tired. I didn't find anything under that heading on the MVPS page either, but there is a lot to look through and I didn't get to it all. I'll check some more tomorrow. Meanwhile, thanks for the help. BTW, a lot of people don't know about that Format Painter button. I found out about it more or less by accident when I happened to stumble into an Office seminar given by Fred Pryor schools. Quote:
> Hi Freya, > > familiar with the Format Painter button? If not, it's the small > Hmm, never used this ... > I had to found how it worked ... > As to copying it's behaviour you could use ... > Have you tried playing around with application events > more specifically, the WindowSelectionChange? > If not: > www.mvps.org > Look up the topic on Application Events > Krgrds, > Perry
> > Thank you, Perry, your code does a nice job, but that's not my problem. > > My code already does the selection and copying just fine. Are you > > familiar with the Format Painter button? If not, it's the small > > paintbrush next to the Cut/Copy/Paste buttons on the Standard toolbar. > > When you single-click it, it copies the format of the text currently > > under the cursor into a hold buffer somewhere and the paintbrush button > > is depressed. You then select some more text and it immediately formats > > that newly selected text to the same format as where the cursor was when > > the button was first clicked, and the paintbrush button is released. > > When you do the same thing, but double-click instead of single-click, > > the effect is the same, except that the button STAYS depressed, and > > every bit of text selected after that is formatted immediately upon > > selection. This continues until the button is released by > > single-clicking it again, pressing ctrl/Z or pressing ESC. There are > > probably other ways to release it as well, but those are the three I > > use. Anyway, THAT'S the effect I'm after - a macro that either runs once > > when I single-click its button on the toolbar, or runs 'continuously' in > > the background, pouncing on any line I select until it is turned off > > again. > > Does this make any more sense?
> > > Hi Freya, > > > You will need to adapt the below example to copy the > selection.range.text > > > to the other document ... > > > Add a UserForm in a project, draw two commandbuttons > > > and a listbox. > > > Commandbutton1 rename to: btnBack > > > Commandbutton1 rename to: btnForward > > > ListBox1 rename to: lstSelectionText > > > Look at below code and how it acts when running the form: > > > Private Sub btnBack_Click() > > > With ActiveDocument > > > .Paragraphs(GetParagrNum - 1).Range.Select > > > btnBack.Enabled = Not (GetParagrNum = 1) > > > btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) > > > End With > > > lstSelectionText = Selection.Range.Text > > > End Sub > > > Private Sub btnForward_Click() > > > With ActiveDocument > > > .Paragraphs(GetParagrNum + 1).Range.Select > > > btnForward.Enabled = Not (.Paragraphs.Count = GetParagrNum) > > > btnBack.Enabled = Not (GetParagrNum = 1) > > > End With > > > lstSelectionText = Selection.Range.Text > > > End Sub > > > Private Sub UserForm_Initialize() > > > ActiveDocument.Paragraphs(1).Range.Select > > > End Sub > > > Private Function GetParagrNum() As Long > > > GetParagrNum = > Selection.Range.Information(wdFirstCharacterLineNumber) > > > End Function > > > Krgrds, > > > Perry
> > > > Yes, that's pretty much the kind of thing I'm trying to do, but I want > > > > the macro to be something I can call from a custom toolbar button in > the > > > > Normal.Dot template with either a single- or double-click, not just > from > > > > a UserForm. Sorry that I didn't make that clearer in the first place. > > > > Format Painter has exactly the kind of behavior I'm trying to copy, > > > > except that I want to do different things than copy a format. The > > > > particular function I'm trying to achieve at the moment is this: > > > > I have written a macro that grabs the line currently containing the > > > > cursor and copies it to the end of the 'other' document currently > open. > > > > The macro works fine - it has all the necessary poop for checking that > > > > there are no more than two documents currently open, if there is only > > > > one it creates the second one, and so on. The user has a sort of > > > > 'master' document from which she creates a second, abbreviated one by > > > > selecting only the appropriate lines for the current situation. The > > > > master itself can change occasionally, and she does that with normal > > > > Word processing, so I can't create a custom form from which she would > > > > just check boxes - it would require my intervention every time the > > > > master changed. > > > > I can speed things up for her by adding a keyboard shortcut to the > > > > macro, but the ideal situation would be to be able to either run the > > > > macro once to grab a praticular line, OR, double-click to turn the > macro > > > > on continuously, so that it would grab a line every time the user > > > > clicked in one, and would continue to do that until it was turned off > > > > again.
> > > > > Hi Freya, > > > > > Looking for somthing like this: > > > > > Dim StopMacro As Boolean > > > > > Private Sub CommandButton1_DblClick(ByVal Cancel As > > > MSForms.ReturnBoolean) > > > > > If Not StopMacro Then > > > > > 'replace msgbox function by your macro ... > > > > > MsgBox "This was a double click" > > > > > StopMacro = True > > > > > Else > > > > > Cancel = StopMacro > > > > > End If > > > > > Exit Sub > > > > > End Sub > > > > > Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal > > > Shift As > > > > > Integer, ByVal X As Single, ByVal Y As Single) > > > > > StopMacro = Not StopMacro > > > > > End Sub > > > > > Krgrds, > > > > > Perry
> > > > > > I have some macros that do things like copy the line containing > the > > > > > > cursor to a new document. I would like to use some of them in a > > > similar > > > > > > way to what Word does with the VBA Controls buttons or the Format > > > > > > Painter button, i.e., when you single-click it, the macro runs > once > > > and > > > > > > quits, but when you double-click it, it would stay active until it > is > > > > > > turned off again with a single-click, ctrl/Z, Esc or similar > actions. > > > > > > Does anyone know how to accomplish this? I have looked through the > > > > > > on-line help and spent many hours in technical bookstores, but not > > > found > > > > > > anything on this subject.
|
Sun, 17 Aug 2003 15:00:18 GMT |
|
 |
Jon Sequeir #10 / 11
|
 Double-click vs single-click on macro button
Subclassing is a Windows API technique whereby you replace a Window's default message handling procedure with your own. But your window procedure will get thousands and thousands of calls that you don't want--you pass these on to the old window procedure--and you raise an event for just the message you're looking for. This is essentially what events like CommandButton_Click are doing under the hood. (Warning: You can't do this with VBA alone, you'll need to write a DLL.) On the first basic of subclassing, check out: http://support.microsoft.com/support/kb/articles/Q168/7/95.asp The other part of the task is iterating through Word's subwindows to find the window handle to the toolbar you want. I've muddled through this myself and can save you the work if you want to see some code. I have a working VB DLL that wraps all this but unless you have VB5 or VB6 and can debug and recompile it as you need, you'll be stuck when a bug comes up. Quote: -----Original Message----- Thanks, that was an interesting article and I'll give it a try. The biggest reason I wanted to mimic the Format Painter behavior was to try keeping things 'standard', or as much so as possible. Double-clicking one button, holding Shift for another, popups for a third - some of these users have been known to freak when the Energy Saver kills the monitor power, and call IT to check their 'broken' new computer. One woman even spent two weeks carrying floppies with her documents to a neighboring office to print them because her printer was broken. She finally worked up the nerve to call and ask if there was anything we could do. I'm NOT making this up - it was unplugged. Anyway, anything I can do to keep them from getting nervous is a plus. You mentioned 'subclassing the toolbar'. That sounds complicated, but I'd like to look at the possibility, except I don't know anything about it. Any special articles you could point me to dealing with that?
> Freyja-- > I've been doing Word VBA programming pretty intensely for a few years, and I know > of no easy way to do this directly. The only types of buttons VBA allows you to > create are combos, popups, and regular old normal buttons. But there might be > another way to accomplish basically the same thing. > You might want to try using a dropdown button offering the different choices, or > have the user hold the Shift key when pressing the button for the extended > option. There's a great article on faking button popups at: > http://msdn.microsoft.com/library/periodic/period99/button.htm > If you're dead set on distinguishing between single- and double-clicks on the > button, I'm pretty certain you'll have to subclass the toolbar. > --Jon Sequeira
> -----Original Message----- > I have some macros that do things like copy the line containing the > cursor to a new document. I would like to use some of them in a similar > way to what Word does with the VBA Controls buttons or the Format > Painter button, i.e., when you single-click it, the macro runs once and > quits, but when you double-click it, it would stay active until it is > turned off again with a single-click, ctrl/Z, Esc or similar actions. > Does anyone know how to accomplish this? I have looked through the > on-line help and spent many hours in technical bookstores, but not found > anything on this subject. > . .
|
Mon, 18 Aug 2003 00:24:56 GMT |
|
 |
Freyj #11 / 11
|
 Double-click vs single-click on macro button
Okay, thanks, but that's getting a little too hairy for me. I looked at the article, and it sounds like a fun rainy day project, but for the moment I'm going to pack it in. The users will just have to learn a little. Appreciate the direction, though, and thanks again. Quote:
> Subclassing is a Windows API technique whereby you replace a Window's default > message handling procedure with your own. But your window procedure will get > thousands and thousands of calls that you don't want--you pass these on to the > old window procedure--and you raise an event for just the message you're looking > for. This is essentially what events like CommandButton_Click are doing under the > hood. (Warning: You can't do this with VBA alone, you'll need to write a DLL.) > On the first basic of subclassing, check out: > http://support.microsoft.com/support/kb/articles/Q168/7/95.asp > The other part of the task is iterating through Word's subwindows to find the > window handle to the toolbar you want. I've muddled through this myself and can > save you the work if you want to see some code. I have a working VB DLL that > wraps all this but unless you have VB5 or VB6 and can debug and recompile it as > you need, you'll be stuck when a bug comes up. > -----Original Message----- > Thanks, that was an interesting article and I'll give it a try. The > biggest reason I wanted to mimic the Format Painter behavior was to try > keeping things 'standard', or as much so as possible. Double-clicking > one button, holding Shift for another, popups for a third - some of > these users have been known to freak when the Energy Saver kills the > monitor power, and call IT to check their 'broken' new computer. One > woman even spent two weeks carrying floppies with her documents to a > neighboring office to print them because her printer was broken. She > finally worked up the nerve to call and ask if there was anything we > could do. I'm NOT making this up - it was unplugged. > Anyway, anything I can do to keep them from getting nervous is a plus. > You mentioned 'subclassing the toolbar'. That sounds complicated, but > I'd like to look at the possibility, except I don't know anything about > it. Any special articles you could point me to dealing with that?
> > Freyja-- > > I've been doing Word VBA programming pretty intensely for a few years, and I > know > > of no easy way to do this directly. The only types of buttons VBA allows you to > > create are combos, popups, and regular old normal buttons. But there might be > > another way to accomplish basically the same thing. > > You might want to try using a dropdown button offering the different choices, or > > have the user hold the Shift key when pressing the button for the extended > > option. There's a great article on faking button popups at: > > http://msdn.microsoft.com/library/periodic/period99/button.htm > > If you're dead set on distinguishing between single- and double-clicks on the > > button, I'm pretty certain you'll have to subclass the toolbar. > > --Jon Sequeira
> > -----Original Message----- > > I have some macros that do things like copy the line containing the > > cursor to a new document. I would like to use some of them in a similar > > way to what Word does with the VBA Controls buttons or the Format > > Painter button, i.e., when you single-click it, the macro runs once and > > quits, but when you double-click it, it would stay active until it is > > turned off again with a single-click, ctrl/Z, Esc or similar actions. > > Does anyone know how to accomplish this? I have looked through the > > on-line help and spent many hours in technical bookstores, but not found > > anything on this subject. > > . > .
|
Mon, 18 Aug 2003 11:48:27 GMT |
|
|
|