|
Ben Williams
Guest
|
Evening all
When using standard outlook FormRegion I use to access the current outlook item formregions with the following:
Dim formregions As WindowFormRegionCollection = Globals.FormRegions
(Globals.ThisAddIn.Application.ActiveInspector())
I then used this to update outlook properties that were defined in a standard windows form.
How do I go about this with a ADX Outlook Form?
Thanks |
|
Posted 24 Mar, 2015 11:42:11
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Hello Ben,
An ADXOlForm is shown either in an Outlook.Explorer or Outlook.Inspector window. Accordingly you need to check ADXOlForm.ExplorerObj and ADXOlForm.InspectorObj; one of them is null (Nothing in VB.NET).
As to getting a form instance, below is a citation from the manual, see the PDF file in the folder {Add-in Express}\Docs on your development PC:
ADXOlFormsCollectionItem.GetForm()
This method returns an instance of your form region in the specified Outlook window.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 25 Mar, 2015 01:19:52
|
|
Top
|
|
Ben Williams
Guest
|
Thanks Andrei
any chance you could knock up the vb.net code please to access the following
current outlook active inspector object
ad express form named PhoneLog
im still new to all this and need as much help as possible hence why im here haha
thanks |
|
Posted 25 Mar, 2015 05:06:32
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Ben,
Active inspector? PhoneLog? Mmm, I'm afraid I don't follow you. Could you explain what you mean?
Below is a raw sketch. This function is located in the ADXOlForm itself. It returns an inspector window in which the form instance is shown.
Public Function GetInspector() as Outlook.Inspector
dim result as Outlook.Inspector = Nothing
if Me.InspectorObj IsNot Nothing Then
result = Me.InspectorObj
' optionally, you can check the item
'dim inspector as Outlook.Inspector = CType(Me.InspectorObj, Outlook.Inspector)
'dim item as Object = inspector.CurrentItem
' if TypeOf item is Outlook.MailItem Then
' result = inspector
' end if
end if
return result
End Function
You can find a number of sample projects at https://www.add-in-express.com/support/addin-vb-net.php#outlook-forms, under the title Outlook forms and views.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 25 Mar, 2015 06:10:01
|
|
Top
|
|
Ben Williams
Guest
|
Sorry Andrei
basically I was coding a standard outlook 2010 form region for journal objects with VS2010. This form called PhoneLog has a datagridview and a button that launched a windows form, this form has a textbox and ok button which when pressed the textbox text is added to the datagridview. I was able to populate the datagridview with the following code within the windows form
Dim formregions As WindowFormRegionCollection = Globals.FormRegions _
(Globals.ThisAddIn.Application.ActiveInspector())
Dim datagridviewlog As DataGridView = formregions.PhoneLog.DataGridView1
Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
datagridviewlog.Rows.Add(Textbox1.text)
End Sub
Just not sure how to perform the same task with add-in express?
Thanks |
|
Posted 25 Mar, 2015 06:42:29
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
You get the ADXOlForm displayed in an Outlook window using ADXOlFormsCollectionItem.GetForm(%an Outlook.Explorer or Outlook.Inspector object representing the window in question%). To access the corresponding ADXOlFormsCollectionItem from outside of the add-in module, you call {project name e.g. MyAddin1}.AddinModule.CurrentInstance.{the ADXOlFormsCollectionItem variable; you should declare it public or friend}.
A raw sketch:
dim activeExplorer as Outlook.Explorer = MyAddin1.AddinModule.OutlookApp.ActiveExplorer()
dim adxForm as AddinExpress.OL.ADXOlForm = MyAddin1.AddinModule.CurrentInstance.adxolFormsCollectionItem1.GetForm(activeExplorer)
if adxForm isNot Nothing Then
dim myForm as PhoneLog = CType(adxForm, PhoneLog)
Dim datagridviewlog As DataGridView = myForm.DataGridView1
End if
Is this what you are looking for?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 25 Mar, 2015 07:25:39
|
|
Top
|
|
Ben Williams
Guest
|
Thanks Andrei but this seems to crash outlook |
|
Posted 26 Mar, 2015 07:10:14
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Hello Ben,
Can you send me your project? You can find the support email address in {Add-in Express installation folder}\readme.txt. Please make sure your email contains a link to this topic. Also specify the code line that crashes Outlook.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 26 Mar, 2015 07:15:20
|
|
Top
|
|
Ben Williams
Guest
|
|
Posted 26 Mar, 2015 09:26:33
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18825
Joined: 2006-05-11
|
Hello Ben,
I strongly recommend setting Option Strict On, see the Compile tab of your project's properties. You'll be able to use Intellisense that helps constructing a chain of calls.
Here's what I get after I modify the very first statement in Form1_Load:
Dim activeItem As Outlook.Explorer = MyAddin2.AddinModule.CurrentInstance.OutlookApp.ActiveInspector().CurrentItem
This doesn't make sense however because what's returned by the right side of the statement cannot fit the left side: an item contained in the active Inspector window cannot be an Outlook Explorer window. The above does compile because 1) CurrentItem is of the Object type and 2) Option Strict is Off.
I suggest that you modify the code so that you pass the instance of ADXOlForm1 (or even, just the datagrid from that form) to the constructor of Form1. In this case, you can save it to a class-level variable that you can declare in Form1 and then access the data grid directly. In the current version, datagrid isn't accessible and you don't see this because Option Strict is On.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 26 Mar, 2015 10:55:20
|
|
Top
|
|