A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

SetFocus for control on built-in form



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 20th 08, 10:31 PM posted to microsoft.public.outlook.program_vba
donchanger
external usenet poster
 
Posts: 2
Default SetFocus for control on built-in form

Is there a way to set the focus to a control on a built-in form in VBA? I
have a macro attached to a button that does a simple substitution in my
signature, but it only works if the "body" of the message has the focus when
I click the button (I'm using SendKeys with a search and replace).

Since the form is "built-in", there is no ModifiedFormPages. Is there a way
to set the focus? Maybe even just a keyboard shortcut?

Thanks for any help or suggestions,

Don

Code Snip:

Sub SrchRepl(Srch, Repl)
'search the message body for the first occurrence of 'srch' and replace
with 'repl'
'need to set the focus in the body (control "message") on the form
SendKeys "{F4}"
SendKeys Srch
SendKeys "{ENTER}"
SendKeys "%{F4}", True
SendKeys Repl, True
End Sub

  #2  
Old February 20th 08, 11:02 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default SetFocus for control on built-in form

How about reworking your code completely and use the Replace function
against the MailItem.Body property? Then you don't have to worry about
control focus at all, and can do away with SendKeys entirely.

--
Eric Legault - MVP - Outlook
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, WSS 3
Application Development, MOSS 2007 Application Development)
Blog: http://blogs.officezealot.com/legault
Try Picture Attachments Wizard for Outlook!
http://www.collaborativeinnovations.ca


"donchanger" wrote in message
...
Is there a way to set the focus to a control on a built-in form in VBA? I
have a macro attached to a button that does a simple substitution in my
signature, but it only works if the "body" of the message has the focus
when
I click the button (I'm using SendKeys with a search and replace).

Since the form is "built-in", there is no ModifiedFormPages. Is there a
way
to set the focus? Maybe even just a keyboard shortcut?

Thanks for any help or suggestions,

Don

Code Snip:

Sub SrchRepl(Srch, Repl)
'search the message body for the first occurrence of 'srch' and replace
with 'repl'
'need to set the focus in the body (control "message") on the form
SendKeys "{F4}"
SendKeys Srch
SendKeys "{ENTER}"
SendKeys "%{F4}", True
SendKeys Repl, True
End Sub



  #3  
Old February 21st 08, 05:23 PM posted to microsoft.public.outlook.program_vba
donchanger
external usenet poster
 
Posts: 2
Default SetFocus for control on built-in form

I thought about that first, but wasn't sure how to handle the various
permutations of BodyFormat (HTML, Plain, RTF). For HTML, I think you have to
use the HTMLBody property, and search/replace twice (because I am replaing an
email address in a signature, which ends up as both text and a "mailto"
link). For Plain, I would search once against the Body property. I have no
idea about RTF format (not sure if/when that would come into play).

In the past, when I tried something similar, the format of the body kept
changing (and dropping attachments sometimes, never could figure out
why/when), but this was using OLK2000.

Yours is a good thought and I guess I'll give that a try since I agree
SendKeys is clunky and I can't get the focus on the right control anyway.

Thanks,

Don

"Eric Legault [MVP - Outlook]" wrote:

How about reworking your code completely and use the Replace function
against the MailItem.Body property? Then you don't have to worry about
control focus at all, and can do away with SendKeys entirely.

--
Eric Legault - MVP - Outlook
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, WSS 3
Application Development, MOSS 2007 Application Development)
Blog: http://blogs.officezealot.com/legault
Try Picture Attachments Wizard for Outlook!
http://www.collaborativeinnovations.ca


"donchanger" wrote in message
...
Is there a way to set the focus to a control on a built-in form in VBA? I
have a macro attached to a button that does a simple substitution in my
signature, but it only works if the "body" of the message has the focus
when
I click the button (I'm using SendKeys with a search and replace).

Since the form is "built-in", there is no ModifiedFormPages. Is there a
way
to set the focus? Maybe even just a keyboard shortcut?

Thanks for any help or suggestions,

Don

Code Snip:

Sub SrchRepl(Srch, Repl)
'search the message body for the first occurrence of 'srch' and replace
with 'repl'
'need to set the focus in the body (control "message") on the form
SendKeys "{F4}"
SendKeys Srch
SendKeys "{ENTER}"
SendKeys "%{F4}", True
SendKeys Repl, True
End Sub




  #4  
Old February 21st 08, 06:17 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default SetFocus for control on built-in form

If you need to alter the formatting, then you'd need to use HTMLBody; but if
you're just replacing text, Body will be fine. Both properties are
co-dependant on each other.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"donchanger" wrote:

I thought about that first, but wasn't sure how to handle the various
permutations of BodyFormat (HTML, Plain, RTF). For HTML, I think you have to
use the HTMLBody property, and search/replace twice (because I am replaing an
email address in a signature, which ends up as both text and a "mailto"
link). For Plain, I would search once against the Body property. I have no
idea about RTF format (not sure if/when that would come into play).

In the past, when I tried something similar, the format of the body kept
changing (and dropping attachments sometimes, never could figure out
why/when), but this was using OLK2000.

Yours is a good thought and I guess I'll give that a try since I agree
SendKeys is clunky and I can't get the focus on the right control anyway.

Thanks,

Don

"Eric Legault [MVP - Outlook]" wrote:

How about reworking your code completely and use the Replace function
against the MailItem.Body property? Then you don't have to worry about
control focus at all, and can do away with SendKeys entirely.

--
Eric Legault - MVP - Outlook
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, WSS 3
Application Development, MOSS 2007 Application Development)
Blog: http://blogs.officezealot.com/legault
Try Picture Attachments Wizard for Outlook!
http://www.collaborativeinnovations.ca


"donchanger" wrote in message
...
Is there a way to set the focus to a control on a built-in form in VBA? I
have a macro attached to a button that does a simple substitution in my
signature, but it only works if the "body" of the message has the focus
when
I click the button (I'm using SendKeys with a search and replace).

Since the form is "built-in", there is no ModifiedFormPages. Is there a
way
to set the focus? Maybe even just a keyboard shortcut?

Thanks for any help or suggestions,

Don

Code Snip:

Sub SrchRepl(Srch, Repl)
'search the message body for the first occurrence of 'srch' and replace
with 'repl'
'need to set the focus in the body (control "message") on the form
SendKeys "{F4}"
SendKeys Srch
SendKeys "{ENTER}"
SendKeys "%{F4}", True
SendKeys Repl, True
End Sub




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multipage control on form not working curram Outlook - Using Forms 5 January 24th 08 10:17 PM
VBScript / SetFocus Chaos in Outlook 2003 Daryll Combs Outlook and VBA 6 December 13th 07 03:26 AM
Form Control Toolbox won't appear Bob Arnett Outlook - Using Forms 0 October 15th 07 11:32 PM
Outlook 2007 Appointment built-in control id for Send button GR Add-ins for Outlook 0 May 22nd 07 10:26 PM
Add Custom Control to Outlook form [email protected] Add-ins for Outlook 2 May 16th 07 05:37 PM


All times are GMT +1. The time now is 07:54 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.