求高手,为什么Application.DisplayAlerts = False不能禁止弹出提示的对话框
合并单元格的时候总是出现“选定区域包含多重数值,合并到一个单元格后只能保留最上角的数据”附上代码:PublicSubOutDataToExcel(FlexAsMSFlex...
合并单元格的时候总是出现“选定区域包含多重数值,合并到一个单元格后 只能保留最上角的数据”
附上代码:
Public Sub OutDataToExcel(Flex As MSFlexGrid) '导出至Excel
Dim s As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
On Error GoTo Ert
Me.MousePointer = 11
Dim Excelapp As Excel.Application
Set xlapp = New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
On Error Resume Next
DoEvents
xlapp.SheetsInNewWorkbook = 3 '将新建的工作薄数量设为1
Set xlBook = xlapp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlBook.Sheets(2).Name = "bookbook" '修改工作薄名称
xlBook.Sheets(3).Name = "book1"
xlSheet.Cells(1, 3) = s
xlapp.Range("C1").Select
xlapp.Selection.Font.FontStyle = "Bold"
xlapp.Selection.Font.Size = 16
With Flex
k = .Rows
For i = 0 To k - 1
For j = 0 To .Cols - 1
DoEvents
xlapp.ActiveSheet.Cells(3 + i, j + 1) = "'" & .TextMatrix(i, j)
Next j
Next i
End With
Range(Cells(3, 1), Cells(4, 1)).Merge
Range(Cells(3, 2), Cells(4, 2)).Merge
Range(Cells(3, 3), Cells(4, 3)).Merge
Range(Cells(3, 4), Cells(3, 10)).Merge
xlapp.DisplayAlerts = False
Range(Cells(3, 4), Cells(3, 10)).HorizontalAlignment = xlCenter '水平居中
xlSheet.Cells.EntireColumn.AutoFit '自动调整列宽
xlapp.ActiveWorkbook.SaveAs "d:\成功"
Me.MousePointer = 0
xlBook.Close (True) '关闭工作簿xlApp.Quit '结束EXCEL对象
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlapp = Nothing '释放xlApp对象
Ert:
Exit Sub
End Sub
合并单元格的时候总是出现“选定区域包含多重数值,合并到一个单元格后 只能保留最上角的数据”
怎么才能取消这个提示呢? 展开
附上代码:
Public Sub OutDataToExcel(Flex As MSFlexGrid) '导出至Excel
Dim s As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
On Error GoTo Ert
Me.MousePointer = 11
Dim Excelapp As Excel.Application
Set xlapp = New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
On Error Resume Next
DoEvents
xlapp.SheetsInNewWorkbook = 3 '将新建的工作薄数量设为1
Set xlBook = xlapp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlBook.Sheets(2).Name = "bookbook" '修改工作薄名称
xlBook.Sheets(3).Name = "book1"
xlSheet.Cells(1, 3) = s
xlapp.Range("C1").Select
xlapp.Selection.Font.FontStyle = "Bold"
xlapp.Selection.Font.Size = 16
With Flex
k = .Rows
For i = 0 To k - 1
For j = 0 To .Cols - 1
DoEvents
xlapp.ActiveSheet.Cells(3 + i, j + 1) = "'" & .TextMatrix(i, j)
Next j
Next i
End With
Range(Cells(3, 1), Cells(4, 1)).Merge
Range(Cells(3, 2), Cells(4, 2)).Merge
Range(Cells(3, 3), Cells(4, 3)).Merge
Range(Cells(3, 4), Cells(3, 10)).Merge
xlapp.DisplayAlerts = False
Range(Cells(3, 4), Cells(3, 10)).HorizontalAlignment = xlCenter '水平居中
xlSheet.Cells.EntireColumn.AutoFit '自动调整列宽
xlapp.ActiveWorkbook.SaveAs "d:\成功"
Me.MousePointer = 0
xlBook.Close (True) '关闭工作簿xlApp.Quit '结束EXCEL对象
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlapp = Nothing '释放xlApp对象
Ert:
Exit Sub
End Sub
合并单元格的时候总是出现“选定区域包含多重数值,合并到一个单元格后 只能保留最上角的数据”
怎么才能取消这个提示呢? 展开
展开全部
要把Application.DisplayAlerts = False语句放在合并单元格语句的前面才行。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询