Populate Outlook form Subject from user-defined fields - vba

I designed the form below:
I would like the Subject to be automatically populated with the value of "[Machine] - [TAT]" as soon as those values are filled. I don't know how to access the values of these fields, the syntax for the value change listeners, nor where I should be putting this code.
When I click "Visual Basic", all I see is this:
It seems that this is only programmatic access to the Application, not the form.
How do I programmatically access the form that I designed?

Legacy form customizations require using VBScript for the "code behind", primarily for interactions with your custom UI. However, VBA macros are used independent of custom forms to work with Outlook items and data. If the business logic for your custom form requires working with the active MailItem, then VBScript is what you need to use.
For your scenario, you need to trap changes to the values of your custom controls. The best practice is to create custom fields in the Outlook item and map those fields to the controls. If you don't, you will only be able to write validation formulas in the designer for those controls, and you cannot trap value changes (odd, I know). Luckily custom fields fire the Item_CustomPropertyChange event, which is exactly what you need.
For more info, see:
Manipulating Controls Programmatically
MailItem.CustomPropertyChange Event

Related

Vba activate grid control as additional control

I want to add control to user GUI that would represent excel like table but I cannot find additional control that would do that. Control like that would be used for easier data entry.
I believe that VBA has control like that and I am missing something obvious.
Does anyone know where to activate control like that?
If you have VB6 installed then, this should work:
Microsoft Flex Grid Control
However, if you do not have (vb6) then, another option is to create one yourself by dynamically adding controls to your UserForm (such as a textbox) and then tracking those object. It would take some work, but it would be an option.

UiPath wont recognize textbox and other controls within userform

I have been working on UiPath for quite some time and I have a form where I need to input certain details.
UiPath won't recognize the controls within the form. This form is designed using power builder and the selector looks something as below
<wnd app='pcemain.exe' cls='FNWNS390' title='Open' />
<wnd cls='pbdw90' />
Since the items and their order in the list won't change; you should be able to use the Send Hotkey activity or Type into activity, or a combination of the two.
In some dropdowns, you can type the whole name of the item.
My tip for these kinds of situations, where the (mouse) controls are
challenging, is to try to do the action manually without using the
mouse (or use it as little as possible). When finding a solution, do
it in UiPath

How Can I Comprehensively Manage my VBA UserForm's Properties?

I am writing my first VBA Add-In under Microsoft Office Word 2007 with Windows 7 Pro/64. Part of this Add-In is a UserForm. Using the Visual Basic editor that runs from Word, I find there are two ways of viewing, and two ways of modifying a UserForm's properties:
View all properties from Object Browser (F2)
View some properties and edit them from Properties Window (F4)
Manually enter and edit any property from the Code window (F7)
Here is a screenshot of my Properties and Code windows:
A problem I find is that the Properties Window contains only a subset of the UserForm's properties (notice that CanPaste, CanRedo, and CanUndo don't appear in Properties), and changes made in the Properties Window are overridden by changes made in the Code window (e.g., at runtime, Me.Caption from the Code window above overrides the Caption field in Properties).
I suppose I should avoid using Properties at all then, and enter all settings via UserForm_Initialize as shown above. But (a) for some settings, Properties makes several settings at once. For example, selecting Verdana Bold from Properties equals Font = Verdana and Font.Bold = True in Code. And (b) it seems Properties sets the subset of properties it controls to defaults of its choosing, and if I change them I can't see what they started out as.
I therefore desire unified and comprehensive access to all my UserForm's properties at once, including the aforementioned default settings. Does anyone know how to reveal a UserForm's default settings as code, or to automatically open all its current settings in the Code window? Is there an umbrella mechanism I'm not aware of?
I'm not a veteran VBA programmer, but I can't believe my experience is unique. I've searched the 'net in vain for a solution. How do you with more experience manage this dilemma?
You use the Properties window to set appearance-related properties at design time. Those property values will then always apply unless you explicitly change them at run-time with VBA code.
Properties that don't relate to appearance, such as CanPaste and CanRedo relate to the state of the form at run-time, so it doesn't make sense to have them configurable at design-time.
You can change nearly all of the properties at run-time, whether it is in the Initialize event or elsewhere. You can even add controls at run-time, but your changes won't be persisted once the instance of the form terminates.

How to identify a specific ActiveX Interface based on limited information

I am in the process of developing an ActiveX control for embedding in Rockwell Automation's Factory Talk View. (See ActiveX DLL Error: Solved to see how great a start I got off to!)
At the moment I have an ActiveX control that seems to embed into the host system OK, but is not fully integrated into the VBA process. I believe that this is because I have not implemented some specific COM interface that is required, but I have no documentation as to what that is. I do know that standard MS controls like the Microsoft Forms 2.0 controls do implement the required interface and fully integrate.
The key functionality I am missing relates to a property that I need to set in order for my VBA code to actually see the ActiveX object. This property can be seen when opening the property panel for any activeX control placed on a Factory Talk screen, but NOT when looking at the properties of ActiveX controls embedded in (for example) Excel. Thus I am probably trying to chase down some custom Rockwell implementation. I am hoping that SO might be able to give me some aid into how to track down what I want based on recognizing the functionality it implements.
Now to the actual property. In Factory Talk the property is called "ExposeToVBA", and has a type "long". You have a choice of 3 values selected from a drop down list:
Not Exposed - When set to this, the controls name is not even visible to VBA code
Type Info Extension - Not sure what this does
VBA Control - VBA code can see and interact with the control.
When I select anything other than "Not Exposed" for my control, I get a warning dialog box with no text on it. For other controls I need to set it to "VBA Control" in order to interact with it in the VBA code (d'oh)
I suspect that the value of this property is translated into some calls to an ActiveX interface on the target control.
The Question
What I want to do is identify what interfaces something like a "Forms 2.0 Label" implements that would match the above functionality. And also perhaps how I could translate this into my C# based control (based on C# ActiveX control (CSActiveX))
I know its a long shot, but I'd appreciate any and all suggestions
This became moot when I found a canned Active-x control that had the functionality that I needed.
FWIW This is what I believe that I used: DMGraph

Interaction between custom forms and event receivers

How can we interact with custom forms and event receivers? How can we talk to custom fields (asp controls) within the custom form from an event recievers?
I searched but cant find something like that or maybe I am not using the right keywords.
In the event receiver you do not have access to any of the controls on a form. What you do have is access to the SPItemEventProperties object which has the BeforeProperties and AfterProperties, er... properties. These are hashtables which contain the names of the SPListItem's fields and their corresponding values (from the form or from the existing item). You can use the event receiver to inspect these values and take a particular action, or even cancel the event.