 |
|
|
|
| Author |
Message |
donchanger
Joined: 20 Feb 2008 Posts: 2
|
Posted: Wed Feb 20, 2008 6:31 pm Post subject: 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
Archived from group: microsoft>public>outlook>program_vba |
|
| Back to top |
|
 |
Eric Legault [MVP - Outlo
Joined: 12 Aug 2007 Posts: 5
|
Posted: Wed Feb 20, 2008 9:02 pm Post subject: Re: 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 @microsoft.com...
> 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
> |
|
| Back to top |
|
 |
donchanger
Joined: 20 Feb 2008 Posts: 2
|
Posted: Thu Feb 21, 2008 1:23 pm Post subject: Re: 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
> @microsoft.com...
> > 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
> >
>
>
> |
|
| Back to top |
|
 |
Eric Legault [MVP - Outlo
Joined: 12 Aug 2007 Posts: 60
|
Posted: Thu Feb 21, 2008 2:17 pm Post subject: Re: 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
> > @microsoft.com...
> > > 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
> > >
> >
> >
> >
|
|
| Back to top |
|
 |
|
|
| Related Topics: | How to know the name of the form user in a folder Config Outlook 2003 SBS 2003 Hi again, I use a personal form wich allow's me to open or create Task's / Contact in diff subFolder of my public folders, the Pb is that in many case there is a customised form in that folder so when I open the item it's disp
Evault custom form & preview pane code Hi all, I'm trying to write a custom form which allows users to perform some tasks before sending. My problem is however that because the form does stuff on startup, recipients get the preview pane active scripting error. We however also have Evault which
Import Outlook Task Form Data Into Access I have several public task folders from which I would like to import the task information into Access including some form data. I've tried the table linking deal but it doesn't include the start date and other form data. I know the EntryIDs and StoreIDs b
Setting/Retreiving a Cooking form a Folder Home Page I've got a .html page with VBScript that successfully writes a cookie and returns the values when the .html page is viewed via IE. However, when the ..html page is hosted within Outlook as a folder home page, the code executes but without writing the cook
Form Control Toolbox won't appear I'm making an email form but I cannot get the Control Toolbox to appear. The button is in the area and it highlights when selected but that's it. I've tried all four ways outlined in the Help files but none of them seem to do anything. |
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|