Hi,
I am new at writing macro and appologize in advance if I am asking stupid questions. I have a macro that I run to change certain fields in the tables and I need to screen print changes. Currently i have a pause build into my macro so that I can print the screen manually but would like to use PRTSCR32 macro instead. I tried to do what was suggested in one of the post and that is to change PRTSCR32 to a function and once I do that I get errors in my macro that i did not have errors before adding that additional line of code. Print macro and job macro included. Any help would be very much appreciated!
Print Macro Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' MACRO NAME: PRTSCR32.EBM (update of 16-bit PRINTSCR.EBM - using OLE Automation)
' WRITTEN BY: Attachmate Automation Support
'DATE WRITTEN: 2/29/96
' DESCRIPTION: This macro prints the host screen for the Active Session Object.
'
' Notes: You must set the FileName$ variable equal to the name of
' your Windows printer prior to running this macro.
'
' This macro will only run with EXTRA! 6.0 or greater.
'
' © Copyright 1989-1996. Attachmate Corporation. All Rights Reserved
'
' This macro is provided as an example only and may need
' to be modified to work in your environment. It is
' provided as is, without warranty or support from
' Attachmate Corporation.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Sub PRTSCR321Sub
' Dimension macro variables and objects
Dim rc%, row%, MaxColumns%, MaxRows%, filenum%
Dim Screenbuf$, linebuf$, FileName$
Dim System As Object
Dim Session as Object
' Get the main system object
Set System = CreateObject("EXTRA.System")
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Aborting macro playback."
Stop
End If
' Get the necessary Session Object
Set Session = System.ActiveSession
If (Session is Nothing) Then
Msgbox "Could not create the Session object. Aborting macro playback."
Stop
End If
' Determine the size of the Presentation Space
MaxRows% = Session.Screen.Rows()
MaxColumns% = Session.Screen.Cols()
' Initialize variables to hold screen information
Screenbuf$ = ""
linebuf$ = Space$ (MaxColumns%)
' Copy the Presentation space
For row% = 1 to MaxRows%
' Get a row of data from the host screen
linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock)
' Store the line read into screenbuf$
screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10)
Next
' Get the next available file number
filenum% = FreeFile
' Open the printer. To print to a file, set FileName$ to a file name.
' In this example, "\\TES\L4S_HP" is a network printer name.
' Change this to your printer name.
FileName$ = "\\s7z4-ipp1\Attachmate-5801-ProcServ1"
Open FileName$ For Output as filenum%
' Print Username at top of page
Print # filenum%, "xxxx " + Chr$ (13) + Chr$ (10)
' Print the screen with a form feed
Print # filenum%, screenbuf$; Chr$ (12)
'Close printer
Close filenum%
End Sub
Job Macro Example including print macro command not working:error msg(Variable OldSystemTimeout undefined)
'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "SESSION1.EDP"
' Date: Tuesday, September 22, 2009 11:40:13
' User: xxxx
'--------------------------------------------------------------------------------
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Global username$
'$Include:"C:\Program Files\EXTRA!\Macros\PRTSCR321.ebh"
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 0100 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' This section of code contains the recorded events
Sess0.Screen.Sendkeys("casn<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
PRTSCR321Sub
Sess0.Screen.Sendkeys("fdsn<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
PRTSCR321Sub
System.TimeoutValue = OldSystemTimeout
End Sub
I am new at writing macro and appologize in advance if I am asking stupid questions. I have a macro that I run to change certain fields in the tables and I need to screen print changes. Currently i have a pause build into my macro so that I can print the screen manually but would like to use PRTSCR32 macro instead. I tried to do what was suggested in one of the post and that is to change PRTSCR32 to a function and once I do that I get errors in my macro that i did not have errors before adding that additional line of code. Print macro and job macro included. Any help would be very much appreciated!
Print Macro Code:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' MACRO NAME: PRTSCR32.EBM (update of 16-bit PRINTSCR.EBM - using OLE Automation)
' WRITTEN BY: Attachmate Automation Support
'DATE WRITTEN: 2/29/96
' DESCRIPTION: This macro prints the host screen for the Active Session Object.
'
' Notes: You must set the FileName$ variable equal to the name of
' your Windows printer prior to running this macro.
'
' This macro will only run with EXTRA! 6.0 or greater.
'
' © Copyright 1989-1996. Attachmate Corporation. All Rights Reserved
'
' This macro is provided as an example only and may need
' to be modified to work in your environment. It is
' provided as is, without warranty or support from
' Attachmate Corporation.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Sub PRTSCR321Sub
' Dimension macro variables and objects
Dim rc%, row%, MaxColumns%, MaxRows%, filenum%
Dim Screenbuf$, linebuf$, FileName$
Dim System As Object
Dim Session as Object
' Get the main system object
Set System = CreateObject("EXTRA.System")
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Aborting macro playback."
Stop
End If
' Get the necessary Session Object
Set Session = System.ActiveSession
If (Session is Nothing) Then
Msgbox "Could not create the Session object. Aborting macro playback."
Stop
End If
' Determine the size of the Presentation Space
MaxRows% = Session.Screen.Rows()
MaxColumns% = Session.Screen.Cols()
' Initialize variables to hold screen information
Screenbuf$ = ""
linebuf$ = Space$ (MaxColumns%)
' Copy the Presentation space
For row% = 1 to MaxRows%
' Get a row of data from the host screen
linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock)
' Store the line read into screenbuf$
screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10)
Next
' Get the next available file number
filenum% = FreeFile
' Open the printer. To print to a file, set FileName$ to a file name.
' In this example, "\\TES\L4S_HP" is a network printer name.
' Change this to your printer name.
FileName$ = "\\s7z4-ipp1\Attachmate-5801-ProcServ1"
Open FileName$ For Output as filenum%
' Print Username at top of page
Print # filenum%, "xxxx " + Chr$ (13) + Chr$ (10)
' Print the screen with a form feed
Print # filenum%, screenbuf$; Chr$ (12)
'Close printer
Close filenum%
End Sub
Job Macro Example including print macro command not working:error msg(Variable OldSystemTimeout undefined)
'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "SESSION1.EDP"
' Date: Tuesday, September 22, 2009 11:40:13
' User: xxxx
'--------------------------------------------------------------------------------
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Global username$
'$Include:"C:\Program Files\EXTRA!\Macros\PRTSCR321.ebh"
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 0100 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' This section of code contains the recorded events
Sess0.Screen.Sendkeys("casn<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
PRTSCR321Sub
Sess0.Screen.Sendkeys("fdsn<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
PRTSCR321Sub
System.TimeoutValue = OldSystemTimeout
End Sub