求助,用vb建xls表格,给单元格赋值,并让几个单元格合并的问题!!
本人用vb6建一个xls文件,在vb中给一些单元格赋值,并合并一些单元格。在vb运行中可看见赋值正常、合并单元格也正常,可保存后,用excel打开,单元格赋值正常,可单元格没有合并,不知道问题出在哪里,请高手指点一下,谢谢!代码如下:Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Private Sub Command1_Click()
If Dir(App.Path & "\RPT\", vbDirectory) = "" Then
MkDir (App.Path & "\RPT")
End If
FileName$ = App.Path & "\RPT\" & Format(Now, "yyyy年mm月dd日") & ".xls"
Open FileName For Binary As #1
Close #1
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Open(App.Path & "\RPT\" & Format(Now, "yyyy年mm月dd日") & ".xls")
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Range("A1:H1").Merge
xlApp.Sheets(1).Cells(1, 1) = "序号"
xlApp.Sheets(1).Cells(2, 1) = "名称"
xlApp.Sheets(1).Cells(2, 2) = "数量"
xlApp.Sheets(1).Cells(2, 3) = "格式"
xlApp.Sheets(1).Cells(2, 4) = "单位"
xlApp.Sheets(1).Cells(2, 5) = "价格"
xlApp.Sheets(1).Cells(2, 6) = "总价"
xlApp.Sheets(1).Cells(2, 7) = "备注"
xlBook.SaveAs FileName:="App.Path & "\RPT\" & Format(Now, "yyyy年mm月dd日") & ".xls""
Set xlSheet = Nothing
xlBook.Close
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub