More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

Login

login
password
Remember me

You will need to register and log in if you want to download the source code for the Microsoft Outlook Programming book. The forums and code sharing areas are open to both registered and non-registered visitors.

forum 02-Sep-2010 22:31

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

 

    Page [ 1 2 Next >> ]  
 Outlook Form Design Printer Friendly Version
Designing custom Outlook forms and form regions and writing code for them
Topic
How to SetFocus in VBScript format
I am attempting to adapt the code on Page 387 of your book the "SetFocus" to VBScript. Is there a similar function to "SetFocus" in VBScript? After a user answers the vbQuestion, I'd like the focus to go to the field that is in question...

-Peter

  17-Mar-2003  12:45
  17-Mar-2003  16:50   
I figured it out...
-Peter
  17-Mar-2003  22:49   
Good for you! Got a snippet you want to share?
  18-Mar-2003  09:34   
Thank you Sue.
-Peter
Here is what I figured out:

Dim objPage
Dim objControl
Function Item_Send ()
  If (item.userproperties.find("priceper2")= 0) and (item.userproperties.find("Oty2")> 0) then
    MsgBox "Please provide an Estimated cost for the line item beginning with " & _
    item.userproperties("Oty2"),,"Dan Says:"
    Set objPage = item.GetInspector.ModifiedFormPages("MTO")
    Set objControl = objPage.Controls("TextBox30")
    objControl.BackColor = RGB (255,0,0)
    objControl.SetFocus
    Item_Send = false
  else

  19-Mar-2003  09:04   
Changing the BackColor property of the control is a nice touch! Just to make sure the user doesn't miss it. I'm going to start using that one in my projects. Thanks for the idea!
  19-Mar-2003  09:49   
Thank you Sue. My humble contributions pale in comparison to the hard work you are doing with assisting and guiding us.
-Peter
  24-Jul-2003  11:56   
I use SetFocus on a multiline TextBox after an error and I display a msgbox, but the insertion bar does not show up in the box, and typing does not enter characters into the field. I think the SetFocus worked, because Tab and Alt-Tab move to the next/prev tabOrder. It looks like the window is active, but I still have to click into the field to get the insertion bar. Any ideas?
  24-Jul-2003  12:16   
Unfortunately, SetFocus doesn't work consistently, so you may be getting the best result you're going to see. See http://www.outlookcode.com/threads.aspx?forumid=3&messageid=489 and and http://www.outlookcode.com/threads.aspx?forumid=3&messageid=1105 for other discussions of SetFocus frustrations.
  27-Aug-2003  01:41   
i can't understand make it simple pls
  27-Aug-2003  09:33   
Deepak, please be specific about what information you are looking for.
  27-Aug-2003  18:06   
I have found that on other than the 1st page, the setfocus method does not display the insertion bar in the control unless the User has clicked on the modified form page at some time through the user interface. Setting the page programatically with the inspector.SetModifiedFormPage method does not seem to be sufficient. The control has the focus, but the insertion bar is hidden.
    Page [ 1 2 Next >> ]  
Post a new message to this topic.



name        email