Macro to Determine if User Has Selected an Area of the Screen
PASSPORT PC to Host, PASSPORT Web to Host
TN3270, TN5250, VT, SCO ANSI, Wyse 60
Is it possible to determine if a user has an area of the screen selected during execution of a macro? If so, we are interested in copying the area that is currently selected. However, if nothing is currently selected, we would like to copy the entire contents of the current screen. Is there a PASSPORT macro function that can do this?
Although there is not a PASSPORT macro function that can do this, below is a sample .ZAM macro that may be used to accomplish this.
Below is a sample PASSPORT macro that uses the Microsoft Word application object to obtain the contents of the Windows clipboard after issuing a PASSPORT copy command. If the variable created contains data it will be displayed in a dialog box. Otherwise, if it is null, the entire screen contents is selected, copied and displayed:
Sub Main ' Set the contents of the clipboard to nothing: strMessage = ""
' Create the Word application object: Set objWord = CreateObject("Word.Application") With objWord .Visible = False ' Don't show word .Documents.Add ' Create a document .Selection.TypeText strMessage ' Put text into it .Selection.WholeStory ' Select everything in the doc .Selection.Copy ' Copy contents to clipboard .Quit False ' Close Word, don't save End With Set objWord = Nothing
' Execute PASSPORT copy command: ExecMenuCmd ("Edit-Copy")
' Set variable to clipboard contents: Set objHTML = CreateObject("htmlfile") strArea = objHTML.ParentWindow.ClipboardData.getData("text")
If strArea <> "" Then MsgBox strArea Else ExecMenuCmd ("Edit-Select All") ExecMenuCmd ("Edit-Copy") Wait(2) strArea = objHTML.ParentWindow.ClipboardData.getData("text") MsgBox strArea End If
Set objHTML = Nothing End Sub |
In order to make use of the PASSPORT Object Layer, you must be using a license code that is enabled for it. For more information, see the following article:
This PASSPORT Version Cannot Run This Type of Macro
The latest Microsoft Visual Basic run-time files must be installed and registered on any workstation that will utilize it. For more information or to download the run-time files, please visit the following page on the Microsoft website:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q192461
macro, area, screen, selected, copy, clipboard, Word, object, .ZAM