Exporting a Host Screen to Microsoft Word
Flex Terminal Emulator allows you to export the contents of a host screen directly into a Microsoft Word document using a macro. This is useful for documentation, reporting, or sharing screen data.
Overview
The macro performs the following actions:
Captures all text from the current host screen
Creates a new Microsoft Word document
Inserts the captured screen content into the document
Displays the document for review or editing
Sample Macro Code
The following example demonstrates how to export the current host screen to a Word document:
- Sub Main()
- ' Create the Word objects
- Set objWord = CreateObject("Word.Application")
- Set objDoc = objWord.Documents.Add
- Set objRng = objDoc.Bookmarks("\endofdoc").Range
- objWord.Visible = true
- Call Word_log(objLine, objRng)
- End Sub
- ' Subroutine to export the host screen data
- Sub Word_log(objLine, objRng)
- nRow = FlexScreen.Rows
- nCol = FlexScreen.Columns
- For i = 1 to nRow
- objLine = FlexScreen.GetText(FlexScreen.Position(i, 1), nCol)
- objRng.InsertAfter objLine
- objRng.InsertAfter vbCRLF
- Next
- End Sub
How It Works
The macro creates a new instance of Microsoft Word and opens a blank document.
It determines the size of the host screen using the number of rows and columns.
Each row of screen text is read and appended to the Word document.
Line breaks are added to preserve the screen layout.
The Word application is made visible so you can review or edit the document.
Notes
The macro automatically detects the host screen size using the Rows and Columns properties.
This allows the entire screen to be exported regardless of its dimensions.
Formatting in Word will reflect the host screen layout, but you may choose to apply a fixed-width font (such as Courier New or Consolas) for better alignment.
Saving and Using the Macro
To use this macro in your environment:
Copy the code into the Flex Terminal Emulator macro editor, or any text editor (such as Notepad).
Save the file with an .ams extension.
Place the file in the Macros subfolder of your Flex Terminal Emulator user directory.
Run the macro from within Flex Terminal Emulator.
This method provides a quick and efficient way to capture and store host screen data in a Word document for future reference or distribution.
Related Articles
Exporting Host Screen Data to Excel Using a Macro
Flex Terminal Emulator allows you to automate the extraction of data from host screens and export it directly into an Excel spreadsheet using a macro. This approach is useful for collecting structured data across multiple screens. Overview A macro ...
Exporting a Host Screen to an Outlook Email
Flex Terminal Emulator allows you to export the contents of a host screen directly into a new Microsoft Outlook email using a macro. This is useful for quickly sharing or documenting screen data. Overview The macro performs the following actions: ...
Supported Host Code Pages in Flex Terminal Emulator
Flex Terminal Emulator supports a range of host code pages to ensure compatibility with different regional and language requirements. Available Host Code Pages The following host code pages are supported: 037 – US / Canada 273 – Austria / Germany 277 ...
Word Wrap in Flex Terminal Emulator Sessions
Flex Terminal Emulator includes a Word Wrap feature that automatically moves text to the next line when it reaches the right edge of the screen. Availability Word Wrap support was introduced in version 7.0.10008.1973 and can be quickly enabled or ...
Recording a Login Macro and Running It Automatically at Startup
Flex Terminal Emulator allows you to automate the login process by recording a macro and configuring it to run each time a session connects to the host. Step 1: Record a Login Macro Follow these steps to capture your login sequence: Open the Flex ...