Button to open explorer and select a file

Add-in Express™ Support Service
That's what is more important than anything else

Button to open explorer and select a file
 
franck DAMMANN




Posts: 41
Joined: 2021-01-26
Dear all,

I'm looking for a way to add a new button on a Ribbon Tab linked to TabNewMailMessage which open an explorer popup to let the end user select a file on its computer and retrieve this file for internal treatment.

Do you have any tutorial to help me on such development ?

Thanks,
Franck.
Posted 04 Oct, 2022 17:17:51 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Franck,

I assume you talk about the drop down on the tab TabMail, group GroupMailNew. If so, the drop down can be customized as a context menu IdMso="MenuMailNewItem"; clicking a button added to that context menu provides the current Explorer object as a context object. I've found this due to the source-code add-in described in https://www.add-in-express.com/creating-addins-blog/2015/04/15/creating-office-context-menu-addin/. That add-in adds a button to every context menu in these Office applications: clicking the button puts the context menu name and the type name of the context object to Clipboard.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Oct, 2022 03:22:13 Top
franck DAMMANN




Posts: 41
Joined: 2021-01-26
Thanks Andrei,

I'll look into it.
Regards,
Franck.
Posted 05 Oct, 2022 05:03:06 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Welcome!

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Oct, 2022 05:06:02 Top
franck DAMMANN




Posts: 41
Joined: 2021-01-26
Andrei,

Sorry May be it was not clear enough.
I would need to create a custom button on a new email item, and when the user clicks on this button it opens an explorer popup to select a file from its computer. I would need to be able to retrieve this file from the outlook addin once it has been selected.

Currently I'm able to add a Custom button no problem but I don't know how to open an Explorer popup to let the user select the file and retrieve the path of the file selected.
Posted 05 Oct, 2022 05:10:35 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Franck,

What do you mean by "explorer popup"?

"to select a file from its computer" means you need to use a FileOpen dialog.

For instance, that can be the OpenFileDialog class; see https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.openfiledialog?view=netframework-4.8.

An Office-style FileOpen dialog would require you to get the Word.Application object from the current inspector and call Word.Application.FileDialog; see https://learn.microsoft.com/en-us/office/vba/api/word.application.filedialog and https://learn.microsoft.com/en-us/office/vba/api/office.filedialog.

Inspector.WordEditor returns a Word.Document object, Document.Application returns the Word.Application.

Release all COM objects created in your code! A mnemonic rule is: every Office object model method/property that returns an object type (not a string, Boolean, enum or number) creates a COM object. Say, Attachments.Add(), ExcelApp.Workbooks, etc.

Regards from Poland (CEST),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Oct, 2022 05:44:31 Top
franck DAMMANN




Posts: 41
Joined: 2021-01-26
yes, sorry it's a fileOpen Dialog....thanks !
Posted 05 Oct, 2022 05:55:17 Top