Outlook 2007 Add-in form containing form with ActiveX control stuck in one off state - vb6

I have an add-in that contains a DLL and an OCX control, built in VB6. Each is separate, meaning that the add-in consists of Addin.DLL and Addin.OCX. The add-in uses a custom form, which is built off of the IPM.Appointment form in Outlook. It is deployed to the user's machine as an OFT file and is published to their Presonal Forms Library in the initial OnConnection of the add-in.
I was having issues with the form being stuck in a one off state, which required me to add code similar the following to my AppointmentItem Write and PropertyChange class:
Private Sub AppointmentItem_PropertyChange(ByVal name As String)
On Error GoTo ErrorHandler
Select Case name
Case "MessageClass"
Dim strGuid As String
' Check to see if this is one of our appointmentitems.
If IsItemUserItem(AppointmentItem_PropertyChange, strGuid) Then
' Change to our add-in message class. IPM.Appointment.XXX
AppointmentItem.MessageClass = gFormMsgClass
End If
End Select
done:
Exit Sub
ErrorHandler:
Trace "Error writing appointment item."
Resume done
End Sub
This works for most cases. However, I'm still running into instances where when I check the item during the NewInspector event if it is an Exception I cannot access UserProperties, which are used to facilitate data sharing between the DLL and OCX.
Additionally when trying to edit the form in the form designer, I cannot save the form as an OFT from Outlook 2007. I'm kind of at a loss as to what is going on with this...Any help is appreciated.

Actually it appears I have my own answer. There were some user-defined properties added to the folder that were not added to the item and they were causing the one off issues.

Related

Outlook 2013 VSTO Addin - How to check if the Mail view is selected?

In an Outlook 2013 VSTO addin (C#), I can check to see if the user is currently in the Calendar area/view by using "if(ActiveExplorer().CurrentView is CalendarView) ..."
How do I do something similar to check and see if the user is in the Mail view, where "Mail" is selected/blue at the bottom of the Outlook window and the user sees their Inbox items? There is no MailView type, or anything similar that I could find, to compare ActiveExplorer().CurrentView, etc., against.
Instead of using the CurrentView property of the Explorer class I'd suggest checking the DefaultItemType property of the Folder class. It returns a constant from the OlItemType enumeration indicating the default Outlook item type contained in the folder.
The CurrentFolder property of the Folder class returns a Folder object that represents the current folder displayed in the explorer. So, the code may look like the following one:
ActiveExplorer().CurrentFolder.DefaultItemType

Outlook addin has failed to find Office control by ID

I've just built an MS Outlook Add In using Visual Studio and Office 2010. I've installed it ok on 4 machines, but one user is getting the following error -
Error found in Custom UI XML of "...."
...
...
Failed to find Office control by ID
Everyone is running Windows 7 and Outlook 2010 - not sure why this person is having a problem. Can anyone suggest how to diagnose this?
For those having similar issues, you don't have to remove any add-in.
What is happening is: Outlook will try to load all ribbons (found in your ribbon xml) into any window the user goes to. Then it'll complain about not finding ID x or y.
Just make sure your GetCustomUI method in Ribbon.cs does not load the entire ribbon XML at once but rather loads it per fragment.
If you're not sure what IDs you need to target, use a breakpoint in GetCustomUI then start Outlook, surf different views (main, new email, new appointment, calendar...etc) in order to gather the IDs for the views wherein you need to show you add-in.
In my case, I needed Microsoft.Outlook.Explorer, Microsoft.Outlook.Mail.Compose and Microsoft.Outlook.Appointment.
Therefore I changed my GetCustomUI to:
public string GetCustomUI(string ribbonID)
{
switch (ribbonID)
{
case "Microsoft.Outlook.Explorer":
return GetResourceText("MyAddin.RibbonsForOutlookExplorer.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("MyAddin.RibbonForOutlookMailCompose.xml");
case "Microsoft.Outlook.Appointment":
return GetResourceText("MyAddin.RibbonForOutlookAppointment.xml");
default:
return null;
}
}
Of course, I had to break down my Ribbon.xml into the three XML files mentioned above. The result: Outlook will ONLY load the fragment needed for a given screen (appointment, new email ...) and will not complain about "not finding an ID on screen X or Y".
Finally, for those who are not sure why some users get that error while others don't: it's because of "Show add-in user interface errors" option (in Options -> Advanced). If that is unchecked then Outlook will ignore the malformed ribbon XML errors. If it checked, users will get related errors about your add-in (if any exists) and also about other add-ins.
If it works for everyone except one user. As #Brijesh Mishra mentioned check if the user has got any other addin and if he is having own quick access tool bar customized.
If he has got any of this then, remove the other addins and try to install or reset the quick access tool bar customization.
For all of you that use a Designer-based VSTO plugin, and not the XML solution.
I searched all the web for this problem, but only found XML-based solutions.
There's nothing for Visual Designer on the web, because in this case you don't have to override the "GetCustomUI" method.
Ribbons designed by using the Visual Designer return a RibbonManager by default.
This RibbonManager object represents all Ribbon (Visual Designer) items in the project and is automatically handled in background through the active window inspector.
So you don't have to write any special code to handle different windows.
To configure it correctly you just have to:
Add one extra Visual Designer Ribbon for every window the user goes to
in the Ribbon Object go under "RibbonType", open the checkbox list an only activate the corresponding window, where the ribbon should appear.
If there is more than one window checked in the list, Outlook trys to insert the ribbon in all the marked windows. Even if the corresponding window is currently not opened. That's the reason, why the error "Failed to find control ID" appears.
the actual fix for me was to separate the ribbon XML files containing the customUI and redirecting to the correct one in the GetCustomUI method (implemented using Office.IRibbonExtensibility)
in example:
public string GetCustomUI(string RibbonID)
{
switch (RibbonID)
{
case "Microsoft.Outlook.Mail.Read":
return GetResourceText("namespace.type1.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("namespace.type2.xml");
default:
return null;
}
}

Why is the OnComm event of MSCOMM32.OCX in Access 2003 VBA missing?

I've dropped the VB6 MSCOMM32.OCX (Microsoft Comm Control 6.0 (SP6)) on to a VBA form. I had to apply a Microsoft Security Update KB926857 to VB6 to get the control to drop on the form because a Windows Update set a kill bit on the older version.
When I look at the object's events in VBA I do not have "OnComm" available. I can get it in VB6 by double clicking its icon (a phone) but not in VBA. Importing it in Delphi shows OnComm as the only event handler.
I know the control is registered properly and licensed.
I've done it a couple of years ago with the older control, but has anybody done this lately?
Available Events: OnEnter, OnExit, OnGetFocus, OnLostFocus & OnUpdated
I discovered independently that HK1's suggestion was correct. I created an event handler that looked like this
Private Sub MSComm1_OnComm()
Nothing needed to be done to the object properties to link it to the routine.
In the form load event I placed an MSCOMM1.PortOpen = True. I scanned a bar code and presto it worked.
Why this is treaded differently than other events I do not know and how/where it is documented is a mystery.
This Microsoft site has helpful information on handling the data properly and is what I used for the test.
http://support.microsoft.com/kb/194922

Create a user in Active Directory from an Infopath form

I've been searching the web for a while now and still can't seem to find anything useful on this topic.
What I am trying to create is a button in my Infopath form that will create a user account in Active Directory. The code will need to pull through information stored in the fields of the Infopath form.
I have chosen to use Visual Basic, as I believe that is a good language scripting with AD.
I have successfully run this code:
Sub CTRL1_12_OnClick(eventObj)
MsgBox "Output: "
End Sub
which returns: 'Output: ' in a VB dialogue box when I click on my infopath button. However, when I try:
Set objOU=GetObject("LDAP://OU=People,OU=contoso,DC=contoso,DC=com")
Set objUser=objOU.Create("user","CN=Linda Mitchell")
objUser.Put "sAMAccountName","linda.mitchell"
objUser.SetInfo()
All I get is an error message in Infopath:
The following error occurred:
ActiveX component can't create object:
'GetObject' File:script.vbs Line:14
When I put the same code in to notepad, save as a vbs file and then execute is runs fine and create a user in active directory, what I don't understand is why when I run the same code it doesn't work.
I would recommend you check out Richard Mueller's web site - he has tons of VBScript code to do all sorts of AD stuff.
Here's a link to a page showing how to create users - is that of help?? I'm not much of a VBScript programmer, but I know Richard's stuff is usually very good and useful.
Here's his entire list of free VBScript code for you to go rummage about!
I have now found out what the problem was. I needed to set the form to 'full trust' Tools>form options> Security and Trust. I also had to sign the form with my certificate.
Now I am able to run the code from that button.

Referencing functions within VB6 User Controls

I'm having an issue referencing public procedures of User Controls that I've created within a VB6 project.
A simple example (exe), I have a form with a button and a user control:
Option Explicit
Private Sub Command1_Click()
UserControl1.updateMessage ("TIME NOW: " & DateTime.Time)
End Sub
The User Control code is as follows:
Option Explicit
Public Sub updateMessage(ByVal newMessage As String)
Label1.Caption = newMessage
End Sub
This exe compiles and works fine, and when I'm typing updateMessage in the Form, it appears in the intellisense list with the appropriate requirements. The issue I have is when I'm wanting to "go to the definition" of updateMessage, instead of going to the appropriate section of the code within the User Control, the message always returns with:
"Cannot jump to 'updateMessage' because it is in the library 'Unknown1' which is not currently referenced."
where the numbered suffix of "Unkown1" changes from time to time.
It seems that if there were no reference to this procedure, then it would not appear in the intellisense and the project shouldn't compile. When running this with MZTools (though the error appears regardless of this plug-in being installed), I can go into the updateMessage procedure, and use it to find all procedures calling this function, so the link between the two should exist (although I'm not sure if MZTools just finds using a text-matching pattern).
If anyone out there could shed some light on this matter, it would be very much appreciated, and save this poor VB6 developer a lot of hassle!
I have SP6 installed (build 9782) of VB6 and am running XP SP3 on an HP dx2400.
Yes, this is extremely annoying and I'm convinced it's a bug in VB6. I say this because, if you locate the updateMessage method in the object browser and double-click on it, you are taken to the definition. So, the compiler actually does know where the definition is, it just refuses to take you there with Shift+F2.

Resources