Attachmate Worldwide  |   Contact Us  |   NetIQ.com
Home » Support » Solution Library

Technical Notes

Error: "Compile error: User-defined type not defined"
Technical Note 2210
Last Reviewed 13-Nov-2008
Applies To
Reflection for IBM 2008
Reflection Standard Suite 2008
Reflection for IBM 2007
Summary

When attempting to use a Reflection Workspace macro that was recorded in Reflection for IBM 2008 or 2007, the following error is displayed: "Compile error: User-defined type not defined." This technical note explains the cause of this error and provides a workaround.

About the Error

This error occurs when a recorded Reflection Workspace macro is run from the common project area. Recorded macros typically contain session object information, which is not supported in the common project area.

Resolving the Error

To resolve this error, do one of the following:

Save the Macro to an Alternate Location

Rerecord the macro and save it to the current document's project, rather than the common project area. Macros saved to the current document's project are available only when the current session is loaded.

To record a macro, follow these steps.

  1. In the Reflection Workspace, open or create a new terminal session.
  2. Click Record Macro.
  3. Perform the tasks you want to automate, and then click Record Macro again.
  4. In the Recording Complete dialog box, enter a Macro name.
  5. Select "Save in the current document's project."

Edit the Macro in Visual Basic

To enable the macro to work when saved to the common area, configure the macro to use the Attachmate_Reflection_Objects_Emulation_IbmHosts library.

Enable the Attachmate Reflection Library

Follow the steps below to edit the macro and enable the Attachmate Reflection library.

  1. Open the macro in the Visual Basic editor.
  2. Click Tools > References.
  3. Select Attachmate_Reflection_Objects_Emulation_IbmHosts, and then click OK.

With this library selected, the macro will now run without the compile error as long as the session indicated in the macro currently has Windows focus.

Edit the currentTerminal Setting

To make the macro session specific whether the session has Windows focus or not, follow these steps while the macro is still open in the Visual Basic editor.

  1. Scroll down to the following line:
Set currentTerminal = ThisFrame.SelectedView.control
  1. Delete this line, or comment it out.
  2. Replace the line with the following code:
Set currentTerminal = ThisFrame.GetViewByTitleText("Name.rd5x").control

Replacing "Name.rd5x" with your session name.

Sample macro with edits made:

        Sub tinymacro()
            Dim currentScreen As IbmScreen
            Dim currentTerminal As IbmTerminal
            Dim frame As frame
            Dim viewList() As View
            Dim hostSettleTimeout As Integer
            Dim hostSettleTime As Integer
            hostSettleTimeout = 2000
            hostSettleTime = 500
            Set viewFrame = Application.GetObject("Frame")
            <!- Comment out or delete this line:
            Set currentTerminal = ThisFrame.SelectedView.control
            ->
            <-! Insert the following line, but replace "Name.rd5x" 
            with your session name. ->
            Set currentTerminal = ThisFrame.GetViewByTitleText("Name.rd5x").control
            Set currentScreen = currentTerminal.Screen
            currentScreen.SendKeys ("1")
            currentScreen.SendControlKey (ControlKeyCode_CMD_TRANSMIT)
            rv = currentScreen.WaitForHostSettle(hostSettleTimeout, hostSettleTime)
        End Sub

  1. Click File > Save common.

The macro will now run without the compile error regardless of which Window has focus as long as the session with the name indicated in the "set currentTerminal=" line is opened (Name.rd5x in the example above).

Related Technical Notes
2183 Developer Tools for Attachmate Products
2211 Technical Notes for Reflection for IBM 2007
9985 Technical Notes for Reflection 2008

Did this technical note answer your question?

Yes    No    Somewhat     Not sure yet

Additional comments about this tech note:

Need further help? For technical support, please contact Support.