Back

Topic

[KB162]Restrictions on executing VBA scripts

Tags: Scripting, VBA

15 years ago
By RM
Options
Print
Applies to:

PcVue version 7.20d onwards.
While the basic content of this article remains valid, details may have changed since it was written.


Summary:

This article describes how to configure PcVue so that VBA scripts are not prevented from running when modal windows are opened in other applications.


Details:

Modal windows

When a modal window is open, it is impossible to access to any other window, e.g. to return to the parent application. In PcVue, a modal window has its Modal property set.

  1. To check that condition, right-click on the window to open its Window Properties dialog.
  2. Check whether the Modal checkbox is ticked.

Window_Properties_Display_tab_modal

VBA scripts and modal windows

The question here is whether VBA scripts are required to run. When a modal UserForm is opened in PcVue, VBA scripts are still executed. This is a default behaviour for PcVue.

However it is not possible to do so with other applications; for instance the act of opening a modal UserForm in Microsoft Excel VBA stops all script execution.

The same limitation applies in PcVue. If you call a native VBA object such as a Message dialog, PcVue’s scripts can no longer run and there is no way to overcome that on the PcVue side.

If you want PcVue to behave like Excel VBA (stopping script execution when a modal PcVue window is open),  you can change the default option in PcVue as follows.

  1. Using a text editor, open the file OPTION.DAT file located in the C folder of the project.
  2. Insert the following line, then save and close the file:

VBA_scripts_modal_Mindows_disable_OPTION_DAT

[GENERAL]

ModalDlgDisableVBA=1

  1. Restart the project to take the setting into account.

Summary of conditions

RestrictionsVBA


Created on: 05 Nov 2010 Last update: 13 May 2024