2
votes

I'm designing a Outlook Contact form. None of the sample code I've tried to put in the View Code button's Script Editor does anything. The most basic example is:

Sub Item_Open()
 msgbox "Hello World"
End Sub

When I click the Run This Form button, no message box or error message appears. It seems to totally ignore the VBScript. The same thing happens with every bit of sample code I've tried.

This is my first time doing any development for Office or in VBA or VBScript, so I assume I'm missing something basic, but I've watched and read a few tutorials, doing exactly what was shown and nothing works. I can design and publish a Contact form with custom fields and and basic combo boxes.

In the Trust Center I have Macro Settings set to "Notifications for all macros" and the Email Security options "Allow script in shared folders" and "Allow script in Public Folders" are both checked.

I'm designing a Contact form using Office 365 32-bit Version 1708 (Build 8431.2079 Click-to-Run) Monthly Channel on Windows 10 x64 Version 1703 Build 15063.608.

Any help would be greatly appreciated!!

Thank you!

2
Did you assign your sub to a button or call the sub from the open event? It's not going to just run itself unless it's in an event.Steve Kline
@Steve Doesn't Sub Item_Open() fire when the form is first opened? I also tried Sub CommandButton1_Click() msgbox "Hello World" End Sub with a CommandButton named that and nothing happened.Matt
It has to be on the form objects instead of an independent module.Steve Kline
@Steve I'm sorry, I don't understand that. Can you give me an example? Or point me to some place with examples? I've found sample code very hard to come by. link link are 2 I've found.Matt

2 Answers

1
votes

The solution was to add some registry keys as described in the 2 articles below. Custom form scripts now require registry settings to be added.

https://support.office.com/en-us/article/Custom-form-script-is-now-disabled-by-default-bd8ea308-733f-4728-bfcc-d7cce0120e94

https://www.slipstick.com/outlook/custom-form-security/

The registry settings mentioned there fixed my issue.

0
votes

Possible causes:

  1. VbScripting is not enabled on your machine, disabled there in Registry, especially on Windows 10. You have to enable there.

  2. Though VbScript is enabled and you can run scripts directly from a file in a Folder like sample.vbs, script may not run on Outlook Custom Form if Outlook application has security setup in Registry Key when installed.

I faced this problem and solved after several attempts.