VBA and UIs

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
rslaav
Posts: 25
Last visit: Sat Oct 01, 2022 6:11 am
Has voted: 2 times

VBA and UIs

Post by rslaav »

I am very new to VBA (I love to hate VB generally), but it seems like I have not choice but to use it to create an Outlook macro that will do some e-mail related tasks with a users clicks on the button. I am curious as to which tool I would use to create the VBA script, and if there's the option of create a UI with it like I am able to with Powershell?

Also, would it be possible to just do this in powershell, have a UI, and perform the same tasks? The issue is that the users are on different versions of outlook, although the majority of them are on Win10.

p.s. I have a license for Powershell Studio.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: VBA and UIs

Post by jvierra »

VBA is not a scripting language. Microsoft Office products have a built-in VBA editor and debugger.

Macros can be created by recording them without any need for writing code.

I recommend posting to a MSOffice user siter for Outlook as that is where to docs and support for Office VBA programing can be found. Amazon and other booksellers have many books on MS Office use and how to work with Office products/

The following link will explain and give you a place to start.
https://docs.microsoft.com/en-us/office ... -in-office
rslaav
Posts: 25
Last visit: Sat Oct 01, 2022 6:11 am
Has voted: 2 times

Re: VBA and UIs

Post by rslaav »

I refer to it as a scripting language as my only exposure to it is from the DOS era, simple Basic. I was linked the following for a way to make a custom add-in https://docs.microsoft.com/en-us/office ... ngenerator but that looks like a javascript solution? I wouldn't mind doing it in javascript, but I didn't realize I could interface with outlook's api that way.

I would prefer to do it entirely in powershell, python, GoLang, or even c#
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: VBA and UIs

Post by jvierra »

That is an add-in and has nothing to do with a VB Application. You will need to learn Outlook and about what a program, application, script and other basic things about computer and software technology. You cannot apply consumer concepts to low level technology. It is critical that you have basic understanding of programmed systems and the fundamentals of computing.

A VBA is a consumer targeted embedded technology that allows end users to alter the behavior of outlook. You will need to learn Outlook and how it is used before trying to do advanced macros. As noted earlier, macros can be recorder with teh macro recorder built into Outlook. Ther is no need to program or script anything.

Start by learning Outlook first. That will get you started and give you an understanding of how Outlook is designed and expected to be used. VBA is part of the fundamentals of Outlook and all Office products.

No language will help you until you understand the product and the technology it is implemented with. Since you are not a trained developer than the languages you reference will not be helpful.

To use any language, you will need to understand which languages can be used. Each one will require some basic understanding of how languages are used with your requirements. Y9u have only stated that you want a macro, but it is clear that you don't even know what an Outlook macro is. Macros can only be created with VBA or the macro recorder. Any other language that accesses Outlook must be a Net language which leaves only C#. You cannot write macros with C#. PowerShell cannot create macros directly and there is likely no reason to create a macro with PowerShell.

Again, you need to learn the basics and then you will be able to understand how to proceed.
dasinmd_
Posts: 1
Last visit: Sun Feb 06, 2022 5:52 am
Been upvoted: 1 time

Re: VBA and UIs

Post by dasinmd_ »

rslaav wrote: Mon Jan 31, 2022 10:40 am I am very new to VBA (I love to hate VB generally), but it seems like I have not choice but to use it to create an Outlook macro that will do some e-mail related tasks with a users clicks on the button. I am curious as to which tool I would use to create the VBA script, and if there's the option of create a UI with it like I am able to with Powershell?

Also, would it be possible to just do this in powershell, have a UI, and perform the same tasks? The issue is that the users are on different versions of outlook, although the majority of them are on Win10.

p.s. I have a license for Powershell Studio.
To address your top-level post (w/o direct links; I'm new to the forum...):

(1) Software*, "VBScript Editor with Debugger": ...vbsedit-com|
(2) Script Help:
----a. VBEdit Samples: ...vbsedit-com|scripts|default.asp
----b. SS64, VB**: ...ss64-com|vb|

_* - this is an excellent utility, and offers easy access to a pre-built 'snippet' directory that you can customize; it is not free, but it offers a 'perpetual trial' mode, with an execution delay built in. You can also try Microsoft's Visual Studio Code application. Have you tried the IDE built into Microsoft Office programs, accessible from the Developer tab?
** - SS64 is my 'go to' for fast help (e.g., FSO Examples: ...com|vb|filesystemobject.html); it's ad-free, format-lite (i.e., easy to copy/paste), and uses succinct, logical examples.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: VBA and UIs

Post by jvierra »

Here is an article you should consider as Microsoft is going to disable VBA macros in Office products. VBA has always been a security risk unless it is used safely which very few techs know how to do. Blocking VBA macros has been coming for some time. Corporations have been using secure and certificated add-ins for a decade to avoid macro issues.

I have always disabled VBA across network wide through Group Policy.

Here is the article about the default blocking of VBA macros.

https://www.theverge.com/2022/2/7/22922 ... ult-change
rslaav
Posts: 25
Last visit: Sat Oct 01, 2022 6:11 am
Has voted: 2 times

Re: VBA and UIs

Post by rslaav »

@jvierra, I appreciate the info. I did notice that as well, and so the question is what is the replacement?
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: VBA and UIs

Post by Alexander Riedel »

You can do a good number of things in VBScript (as opposed to VBA), which you should be familiar with. PrimalScript is a good choice to edit, debug and package these scripts.
You can also use the COM interfaces Office products expose from PowerShell.
https://adamtheautomator.com/powershell-excel/
This is a good illustration as it shows using specialized cmdlets alongside the more generic COM object interfaces. It uses Excel, but you can similar things with all Office products.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 2 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked