GSerg писал(а):В том и может быть причина этого, что надо указывать, какие cells и где.
Private Sub btnExport_Click()
Dim i As Integer
Dim j As Integer
'создание динамического объекта-приложения
Set xlApp = New Excel.Application
'создание книги внутри приложения
Set xlBook = xlApp.Workbooks.Add
'создание рабочего листа книги
Set xlSheet = xlBook.Worksheets(1)
'показать рабочий лист книги
xlSheet.Application.Visible = False
j = 1
dtFind.Recordset.MoveFirst
Do While Not dtFind.Recordset.EOF
With xlSheet
.Columns("a").ColumnWidth = 6
.Columns("b").ColumnWidth = 20
.Columns("c").ColumnWidth = 24
.Columns("d").ColumnWidth = 4
.Columns("e").ColumnWidth = 24
.Name = "Выписка"
.Range(Cells(1 + (j - 1) * 27, 2), Cells(1 + (j - 1) * 27, 5)).Merge
.Cells(1 + (j - 1) * 27, 2) = "Учетная карточка"
With .Range(Cells(1 + (j - 1) * 27, 2), Cells(1 + (j - 1) * 27, 5))
.Font.Size = 16
.Borders.Color = vbBlack
.Borders.Weight = 3
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
.Range(Cells(2 + (j - 1) * 27, 2), Cells(2 + (j - 1) * 27, 5)).Merge
With .Range(Cells(2 + (j - 1) * 27, 2), Cells(2 + (j - 1) * 27, 5))
.Font.Size = 12
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
With .Range(Cells(4 + (j - 1) * 27, 2), Cells(21 + (j - 1) * 27, 5))
.Font.Size = 8
.Borders.Color = vbBlack
.Borders.Weight = 2
End With
With .Range(Cells(4 + (j - 1) * 27, 3), Cells(21 + (j - 1) * 27, 5))
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
.Cells(2 + (j - 1) * 27, 2) = "Корпус: " & dtFind.Recordset.Fields(0) & ", Аудитория: " & dtFind.Recordset.Fields(1) & ", Имя компьютера: " & dtFind.Recordset.Fields(2)
.Range(Cells(3 + (j - 1) * 27, 2), Cells(3 + (j - 1) * 27, 5)).Merge
.Cells(3 + (j - 1) * 27, 2) = "IP адрес:" & dtFind.Recordset.Fields(19)
.Cells(4 + (j - 1) * 27, 2) = "блок питания"
.Cells(5 + (j - 1) * 27, 2) = "материнская плата"
.Cells(6 + (j - 1) * 27, 2) = "процессор"
.Cells(7 + (j - 1) * 27, 2) = "видеокарта"
.Cells(8 + (j - 1) * 27, 2) = "аудиокарта"
.Cells(9 + (j - 1) * 27, 2) = "оперативная память"
.Cells(10 + (j - 1) * 27, 2) = "оперативная память"
.Cells(11 + (j - 1) * 27, 2) = "оперативная память"
.Cells(12 + (j - 1) * 27, 2) = "жесткий диск"
.Cells(13 + (j - 1) * 27, 2) = "жесткий диск"
.Cells(14 + (j - 1) * 27, 2) = "жесткий диск"
.Cells(15 + (j - 1) * 27, 2) = "дисковод"
.Cells(16 + (j - 1) * 27, 2) = "сетевая плата"
.Cells(17 + (j - 1) * 27, 2) = "привод"
.Cells(18 + (j - 1) * 27, 2) = "привод"
.Cells(19 + (j - 1) * 27, 2) = "монитор"
.Cells(20 + (j - 1) * 27, 2) = "клавиатура"
.Cells(21 + (j - 1) * 27, 2) = "мышь"
.Cells(4 + (j - 1) * 27, 3) = Trim(dtFind.Recordset.Fields(3))
.Cells(5 + (j - 1) * 27, 3) = Trim(dtFind.Recordset.Fields(4))
.Cells(6 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(5)
.Cells(7 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(6)
.Cells(8 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(7)
.Cells(9 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(8)
.Cells(10 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(9)
.Cells(11 + (j - 1) * 27, 3) = Trim(dtFind.Recordset.Fields(37))
.Cells(12 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(10)
.Cells(13 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(11)
.Cells(14 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(36)
.Cells(15 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(12)
.Cells(16 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(13)
.Cells(17 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(14)
.Cells(18 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(15)
.Cells(19 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(16)
.Cells(20 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(17)
.Cells(21 + (j - 1) * 27, 3) = dtFind.Recordset.Fields(18)
.Cells(4 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(20)
.Cells(5 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(21)
.Cells(6 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(22)
.Cells(7 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(23)
.Cells(8 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(24)
.Cells(9 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(25)
.Cells(10 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(26)
.Cells(11 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(39)
.Cells(12 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(27)
.Cells(13 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(28)
.Cells(14 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(38)
.Cells(15 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(29)
.Cells(16 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(30)
.Cells(17 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(31)
.Cells(18 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(32)
.Cells(19 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(33)
.Cells(20 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(34)
.Cells(21 + (j - 1) * 27, 5) = dtFind.Recordset.Fields(35)
For i = 3 To 21
.Cells(i + (j - 1) * 27, 4) = "S/N"
Next i
End With
dtFind.Recordset.MoveNext
j = j + 1
Loop
xlSheet.Application.Visible = True
End Sub
.Range(Cells(1 + (j - 1) * 27, 2), Cells(1 + (j - 1) * 27, 5)).Merge
.Cells(1 + (j - 1) * 27, 2) = "Учетная карточка"
Сейчас этот форум просматривают: SemrushBot, Yandex-бот и гости: 97