How to open and display incoming mails in outlook using VB? (Not VBA) - vb.net

I've been struggling recently with a simple Windows Form Application that helps me automate common outlook tasks.
I know that triggering a "Display" event everytime a new email arrives is quite simple, but I'm still a noob when it comes to Visual Basic.
I must mention that all the information I've found so far deals only with VBA code and it seems that statements differ between VBA and VB.
Any ideas, suggestions or recommendations of useful websites to look at will be greatly appreciated.
Thanks

The Concepts (Outlook 2013 developer reference) section provides a lot of HowTo pages with VB.NET samples.
I've been struggling recently with a simple Windows Form Application
It looks like you are trying to automate Outlook. In that case you may find the How to automate Outlook by using Visual Basic article helpful.
As an alternative way, you may consider developing an Outlook add-in. See Walkthrough: Creating Your First Application-Level Add-in for Outlook to get started quickly. See also the Outlook Solutions section in MSDN.

Related

Export a Outlook form written in VBA

I recently wrote a form in VBA for Outlook and saved it to my personal form folder.
Now this form should get exported in a userfriendly fashion. What is the best practise here?
I know that you can go to File -> Export file... in VBA, but this seems to have caused some problems in the past and doesn't seem very intuitive to use both the frm and the frx files.
The form is supposed to be accessed by employees to book their holiday.
That is COM add-ins were invented for. They are designed to be installed on multiple machines and users. VBA macros are not designed for transferring the code - the infrastructure doesn't provide anything for moving solutions automatically like you could do in case of COM add-ins. You need have do that manually in VBA.
If you consider moving your solution to the add-in rails, see Walkthrough: Create your first VSTO Add-in for Outlook to get started quickly. You may choose VB.NET which has a similar syntax with VBA.

How can I expose Word VBA macro code as text files in VSC to better commit and track code changes?

Background and Problem
I lead a team of tech writers. Our team has a Word template (.dotm file) that has a bunch of VBA macros we've created over the years to help us automate tasks in Word. The macros are obviously stored inside of a .dotm template. Given that the code is stored in a binary file, the code is not easily traceable across commits.
Currently, we have to pull the changes on the branch and then open the macro inside Word's embedded code editor from the .dotm. But there's no way to see what exact code changes someone else made line by line or resolve conflicts using something like Beyond Compare.
What I Need
I'd like to find a way to automatically expose the VBA code from the .dotm as some kind of text file so that we can:
Do Word VBA coding tasks within VSC
Easily track and review each others code changes at the line level using our git repository
Resolve merge conflicts more easily
Has anyone found a way to do this?
What I've tried
I've tried searching online and on stackoverflow.
Hoping it might help, I installed ScriptLab, and I after following the MS tutorial, I now have Office Add-Ons working with VSC.
(https://code.visualstudio.com/docs/other/office),
(https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/word-tutorial) While the Office Add-Ons through VSC does provide an alternate (more modern) way of automating using Javascript, and the .js files are commit-able, it's not providing a way to expose the Word VBA, at least not that I could see.
Thank you in advance!
ScriptLab add-on is for playing with JavaScript code instantly, not designed as a macro infrastructure in Office.
Sounds like you need to switch your VBA macros to COM add-ins rails. There is no converters that can do this part of work for you automatically.
You may consider creating a VB.NET based add-in. In that case you will avoid language translating issues. You may find the Converting Code from VBA to Visual Basic .NET article helpful. It presents issues to consider when converting your Microsoft Office solutions from Visual Basic for Applications (VBA) to Visual Basic .NET. Provides a general overview of their differences, and then uses examples from Word and Excel to describe how you can use Visual Studio Tools for the Microsoft Office System to convert your code.

How to move existing Outlook VBA code into an Outlook add-in?

I am trying to develop add-ins because my organization wants to move away from macros, due to the logistical tasks of deploying to thousands of users.
Is there a guide to repurpose existing VBA code into add-ins?
I want to be able to view/modify the source code.
Most helpful article so far:
https://blogs.msdn.microsoft.com/csharpfaq/2010/09/27/converting-a-vba-macro-to-c-4-0/ where they suggest "recording a macro in Office and then use the results in their code in VS".
I'm not aware of any VBA to VB.NET conversion tools, but the similarities are enough that you can copy and paste most code and correct the differences on the individual lines that prevent compilation. However it would be necessary to have a decent working knowledge of VB.NET in order to do this effectively.
I would though recommend that this task be considered a complete re-write, especially since you need to port it to an add-in project. The way you call your VBA methods may differ greatly depending on whether they are event or UI/Ribbon driven.
Also note that there is no macro recorder for Outlook.

Converting powerpoint VBA add-in (.ppam) to COM add-in (.dll)

I have created a working Powerpoint add-in (.ppam) that offers several time saving features, and added a custom UI ribbon tab to improve accessibility.
As I look to distribute this add-in to users, I'm looking to improve code security by compiling it into a COM add-in (.dll) via VS Express.
I have looked all over the web for documentation on this, and have found some promising source, such as:
http://www.cpearson.com/excel/creatingcomaddin.aspx
Unfortunately, nearly everything I find appear to be quite outdated and based on Office XP or 2003, when I'm looking at Office 2010. I'm probably doing something wrong here, but I'm having trouble replicating their instructions on my end, running into errors like being unable to add a reference library or the code they suggest is not recognized. I actually am even unsure how to open for example the sample VB project that the Pearson site provides from the link above to imitate. I think all this may be because of the different versions of Office and Visual Studio, but could certainly be wrong.
Could anyone point me in the right direction? My understanding is that it's actually quite simple to convert the code from VBA to VB (just involves adding "Powerpoint.Application." in front of things like "activewindow"). So I just need to figure out how to convert a very simple VBA add-in into a COM add-in in VS Exp 2012 for Office 2010, and then can leverage the process to convert the full add-in.
Apologies if I'm using any of the terms incorrectly.

Using the Office Interop for Word and Outlook 2007 in VB.NET

I need interop in my programs to automate several functions in Word and Outlook. Does anyone know a good place to start. My goal is to kick off a mail merge, create several different files and save them accordingly, then e-mail the different files to different people based upon who needs what. Any help learning how to use the interop properly would be greatly appreciated.
I am currently using Visual Studio 2008 and Office 2007 and use vb.net to write my programs.
A good way to get started is to use the macro editor to record the steps you are trying to perform. You can take the generated macro code and modify it for your purposes to suit. Click on the names of functions and variables of which you do not know the purpose and hit "F1" to get context specific help.
Add COM references to Outlook 12.0 Object library and Word 12.0 Object library.
This web page really helped kick me off: http://support.microsoft.com/kb/316383
Then, by recording macros you'll expose a lot of the stuff you'll likely want to work with. Word of warning, however, is that not everything exposed in VBA (macros) is accessible within VB .NET. I don't know why this is, but I've actually had to construct and execute a macro from VB.NET, written in VBA, within Excel to accomplish something that seemed ridiculously easy if it weren't for the strange disconnect between the two.
Some good info on Mail Merge: http://support.microsoft.com/kb/258512
Here's an article with some basic steps to get you up and connected with Outlook's Interop: http://support.microsoft.com/kb/313787
Hope this helps. I'll keep an eye out for questions from you here--I'd say I know quite a bit when it comes to interop.
You might want to start here: http://msdn.microsoft.com/en-us/office/bb266408.aspx.
There are a number of tutorials.