Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '(globál deklarációk)
  2.    Dim FileName As String
  3.     Dim Path As String
  4.     Dim Partnumber As String
  5.     Dim Revision As String
  6.     Dim SysDate, SysTime As String
  7.     Dim InvDoc As Document
  8.  
  9. '(fő program lényegében:)
  10. Public Sub izé()
  11.         Call StüLiExport
  12. end sub
  13.  
  14. '(ez a szopó szubrutin)
  15. Private Sub StüLiExport()
  16.         SysTime = Format(Time, "HH:MM")
  17.         SysDate = Format(Date, "mm.dd.yy")
  18.         For i = 1 To InvDoc.Sheets.Count
  19.             If InvDoc.Sheets.Item(i).PartsLists.Count > 0 Then
  20.                 Dim StüLi As PartsList
  21.                 Set StüLi = InvDoc.Sheets.Item(i).PartsLists.Item(1)
  22.                 Exit For
  23.             End If
  24.         Next
  25.         Dim XLSFileName As String
  26.         XLSFileName = Path & FileName & Revision & ".xls"
  27. ' innen az érdekes:
  28.        Dim ExcelApp As Excel.Application
  29.         Set ExcelApp = New Excel.Application
  30.         Dim ExcelWB As Excel.Workbook
  31.         Set ExcelWB = ExcelApp.Workbooks.Add
  32.         Dim ExcelWS As Excel.Sheet
  33.         Set ExcelWS = ExcelWB.ActiveSheet
  34.         With ExcelWS
  35.             For o = 1 To StüLi.PartsListColumns.Count
  36.                 .Cells(1, o).Value = StüLi.PartsListColumns.Item(o).Title
  37.                 .Cells(1, o).Font.Bold = True
  38.                 .Cells(1, o).BorderAround LineStyle:=xlSolid, Weight:=xlThin, ColorIndex:=xlColorIndexAutomatic
  39.                 .Cells(1, o).HorizontalAlignment = xlCenter
  40.             Next o
  41.             For s = 1 To StüLi.PartsListRows.Count
  42.                 For o = 1 To StüLi.PartsListRows.Item(s).Count
  43.                     .Cells(s + 1, o).Value = StüLi.PartsListRows.Item(s).Item(o).Value
  44.                     .Cells(s + 1, o).BorderAround LineStyle:=xlSolid, Weight:=xlThin, ColorIndex:=xlColorIndexAutomatic
  45.                     .Cells(s + 1, o).HorizontalAlignment = xlLeft
  46.                 Next o
  47.             Next s
  48.             o = o - 1
  49. ˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇˇ
  50. 'ez a gond:
  51.            .Range(Cells(1, 1), Cells(s, o)).BorderAround LineStyle:=ExcelApp.xlSolid, Weight:=xlMedium, ColorIndex:=xlColorIndexAutomatic
  52. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  53.            .Columns.AutoFit
  54.             .Cells(s + 1, 1).Value = "Exportálva: " & SysDate & " " & SysTime
  55.             .Cells(s + 2, 1).Value = "(File: " & InvDoc.FullFileName & ")"
  56.             .Name = "Stückliste"
  57.         End With
  58.         ExcelWB.SaveAs FileName:=XLSFileName, FileFormat:=xlExcel8
  59.         ExcelWB.Close False
  60.         ExcelApp.DisplayAlerts = False
  61.         ExcelApp.quit
  62.         Set ExcelWS = Nothing
  63.         Set ExcelWB = Nothing
  64.         Set ExcelApp = Nothing
  65.         On Error GoTo 0
  66. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement