Dim cj As WinForm.textBox = e.Form.Controls("导入报表文件")
If cj.Text = "" Then
messagebox.show("请输入文件名!")
Else
Dim App As New MSExcel.Application
Dim aa As String
Dim n As Integer
n=0
aa=vars("aa")
If MessageBox.Show("是否将链接粘贴回数值,估计每个表要20秒?","确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) =DialogResult.OK Then
For Each file As String In filesys .GetFiles(ProjectPath & aa)
If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
Dim Wb As MSExcel.Workbook = App.WorkBooks.open(file)
Dim aa1() As String = {"分户快报","资产负债表","利润及分配表","费用表","工资月报","附列资料"}
For Each a1 As String In aa1
Dim ws As MSExcel.WorkSheet = Wb.WorkSheets(a1)
If Wb.WorkSheets(a1) Is Nothing Then
Ws.UnProtect
Dim ds() As String = {"'C", "'D", "'E"}
Dim Rg As MSExcel.Range = Ws.UsedRange
Dim ary = rg.Formula
For i As Integer = 1 To Ws.UsedRange.Rows.Count
For j As Integer = 1 To Ws.UsedRange.Columns.Count
For Each d As String In ds
If ary(i,j) > "" AndAlso (ary(i,j).Toupper.StartsWith("=" & d) OrElse ary(i,j).StartsWith("=ge(") OrElse ary(i,j).StartsWith("=-ge(")) Then
ws.cells(i,j).copy
ws.cells(i,j).PasteSpecial(Paste:=MSExcel.XlPasteType.xlPasteValues, Operation:=MSExcel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, SkipBlanks:=False, Transpose:=False)
End If
Next
Next
Next
End If
Next
Wb.Save
App.Quit
n=n+1
End If
Next
App.Quit
messagebox.show("粘贴完成" & n & "个!")
End If
End If