我在编程中,需要合并excel表格,但是表格中都有数据,这样的话在合并的时候,excel就会报一个警告,需要点“确定”才能通过。我怎样才能把这个确定动作不用手动完成,而用程序实现,或者怎么把这个确定省略掉?谢谢!!!!

解决方案 »

  1.   

    dim xlsApp as Excel.Application
    .
    .
    .
    xlsApp.DisplayAlerts = False
      

  2.   

    Private Sub Command1_Click()
    Dim xlsap As New Excel.Application
    Dim xlsbook As Excel.Workbook
    Dim xlssheet As Excel.Worksheet
    xlsap.Visible = True
    Set xlsbook = xlsap.Workbooks.Add
    Set xslsheet = xlsbook.Worksheets("sheet1")
    Cells(1, 1) = "abc"
    Cells(1, 2) = "xyz"
    xlsap.DisplayAlerts = False
       Range("A1:B1").Select
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .ShrinkToFit = False
            .MergeCells = False
        End With
        
        Selection.Merge
        
    '.....    End Sub
      

  3.   

    Up一下
    xlsApp.DisplayAlerts = False