Добрый день всем! Прошу помощи! Документ, например, список абитуриентов (или что нибудь др.) вывожу в Excel, где обрабатывается информация,... и выводится на печать. Отсылаю в MSExcel так:
| Код | Private Sub cmdExcel_Click() On Error Resume Next Dim iIndx As Integer Dim iRowIndex As Integer Dim iColIndex As Integer Dim iRecordCount As Integer Dim iFieldCount As Integer Dim sMessage As String Dim avRows As Variant Dim excelVersion As Integer
'-- Read all of the records into our array avRows = adoRecordset.GetRows()
'-- Determine how many fields and records iRecordCount = UBound(avRows, 2) + 1 iFieldCount = UBound(avRows, 1) + 1
'-- Create reference variable for the spreadsheet Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True On Error Resume Next Select Case cmbDokumentt Case cmbDokument(1) ' === Общий список === objExcel.Workbooks.Open (App.Path & "\Doc\Главная книга учета") ........................................ Case cmbDokument(20) ' === Список заочного отделения=== objExcel.Workbooks.Open (App.Path & "\Doc\PriemZO") Case Else End Select '-- We need this line to insure Excel remains visible if we switch Set objTemp = objExcel
excelVersion = Val(objExcel.Application.Version) If (excelVersion >= 8) Then Set objExcel = objExcel.ActiveSheet End If
'-- Place the names of the fields as column headers -- iRowIndex = 1 iColIndex = 1 For iColIndex = 1 To iFieldCount With objExcel.Cells(iRowIndex, iColIndex) .Value = adoRecordset.Fields(iColIndex - 1).Name With .Font .Name = "Times New Roman" .Bold = True .Size = 12 End With End With Next
'-- memory management -- adoRecordset.Close Set adoRecordset = Nothing
'-- Just add data -- With objExcel For iRowIndex = 2 To iRecordCount + 1 For iColIndex = 1 To iFieldCount .Cells(iRowIndex, iColIndex).Value = avRows(iColIndex - 1, iRowIndex - 2) Next Next End With objExcel.Cells(1, 1).CurrentRegion.EntireColumn.AutoFit End Sub
|
Все работает в офисе 97. На одном компе стоит офис XP, и документы не открываются. В коде указано:
| Цитата | | If (excelVersion >= 8) Then |
значит, не та версия. Как указать, чтобы могли открываться все версии Excel? Этот фрагмент кода я позаимствовал из обной умной книги. Подскажите, pse, кто может. С уважением |