Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra to Excel - Print Preview Question

Status
Not open for further replies.

Losman500

Technical User
Oct 9, 2007
43
0
0
US
I'm running an Extra Basic macro that populates Excel from an Extra screen, I want excel to display in Print Preview which works, but as soon as I close print preview the macro crashes with this message: MS Excel unable to set the PrintPreview property to the worksheet class LINE 29. Any help is much appreciated. This is my code
Code:
Sub Main()
   Dim Sys As Object, Sess As Object

   Set Sys = CreateObject("Extra.System")

   If Sys Is Nothing Then
      MsgBox ("Could not create Extra.System...is E!PC installed on this machine?")
      Exit Sub
   End If

   Set Sess = Sys.ActiveSession

   If Sess Is Nothing Then
      MsgBox ("No session available...stopping macro playback.")
      Exit Sub
   End If

   If UCase(Sess.Screen.GetString(1, 2, 4)) = "INSP" Then
      Dim ObjExcel As Object, ObjWorkbook As Object, ObjWorksheet As Object, result As String

      Set ObjExcel     = CreateObject("Excel.Application")
      Set ObjWorkbook  = ObjExcel.Workbooks.Open("C:\Documents and Settings\My Documents\Attachmate\EXTRA!\Large Label.xls")
      Set ObjWorksheet = ObjWorkbook.Sheets("Sheet1")
      ObjExcel.Visible = True
      ObjWorksheet.PrintPreview = True


 result = Sess.Screen.GetString(4, 9, 26)
 ObjWorkbook.Worksheets("Sheet1").Cells(4, 1).Value = result  'OPN
 
 result = Sess.Screen.GetString(4, 68, 14)
 ObjWorkbook.Worksheets("Sheet1").Cells(7, 4).Value = result  'SER
 
 result = Sess.Screen.GetString(4, 47, 10)
 ObjWorkbook.Worksheets("Sheet1").Cells(11, 4).Value = result  'KWD
 
 result = Sess.Screen.GetString(1, 7, 13)
 ObjWorkbook.Worksheets("Sheet1").Cells(15, 4).Value = result  'UCN
 
 result = Sess.Screen.GetString(08, 32, 5)
 ObjWorkbook.Worksheets("Sheet1").Cells(11, 12).Value = result  'SHQ
      
      Set ObjWorksheet = Nothing
      Set ObjWorkbook  = Nothing
      Set ObjExcel     = Nothing
   Else
      MsgBox "You must be in the INSP screen to run macro."    ' Displays a message box if not in RGAM
   End If

   Set Sess = Nothing
   Set Sys  = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top