阅: 2315 | 回: 0
等级:初学者
- 积分:0
- 财富值:0.0
- 身份:普通用户
Public strPath(1000) As String
Public strBookName(1000) As String
Public Function OpenExcelFile(nFileNum As Integer) As String
Dim nCount As Integer
For nCount = 1 To nFileNum
strPath(nCount) = pplication.GetOpenFilename(fileFilter:="Microsoft Excel(*.xls), *.xls,Microsoft Excel(*.xlsx), *.xlsx")
If strPath(nCount) = "False" Then
MsgBox "Excel 文件错误", vbCritical
Exit Function
End If
Workbooks.Open Filename:=strPath(nCount), UpdateLinks:=0,
ReadOnly:=False
strBookName(nCount) = ActiveWorkbook.Name
Next nCount
End Function
Sub ModifyFiles()
Dim vFileNum As Variant
vFileNum = Trim(InputBox("10:"))
If vFileNum < 1 Or vFileNum > 1000 Then
MsgBox "数量错误", vbCritical
Exit Sub
End If
OpenExcelFile (vFileNum)
Dim nCountFile As Integer
For nCountFile = 1 To vFileNum
If strPath(nCountFile) = "False" Then
Exit Sub
End If
Next nCountFile
Application.DisplayAlerts = False
For nCountFile = 1 To vFileNum
Workbooks(strBookName(nCountFile)).Activate
Dim sht As Worksheet
For Each sht In Worksheets
sht.[D7] = 1
Next
Workbooks(strBookName(nCountFile)).Close True
Next nCountFile
Application.DisplayAlerts = True
MsgBox "完成!", vbInformation
End Sub
Public strBookName(1000) As String
Public Function OpenExcelFile(nFileNum As Integer) As String
Dim nCount As Integer
For nCount = 1 To nFileNum
strPath(nCount) = pplication.GetOpenFilename(fileFilter:="Microsoft Excel(*.xls), *.xls,Microsoft Excel(*.xlsx), *.xlsx")
If strPath(nCount) = "False" Then
MsgBox "Excel 文件错误", vbCritical
Exit Function
End If
Workbooks.Open Filename:=strPath(nCount), UpdateLinks:=0,
ReadOnly:=False
strBookName(nCount) = ActiveWorkbook.Name
Next nCount
End Function
Sub ModifyFiles()
Dim vFileNum As Variant
vFileNum = Trim(InputBox("10:"))
If vFileNum < 1 Or vFileNum > 1000 Then
MsgBox "数量错误", vbCritical
Exit Sub
End If
OpenExcelFile (vFileNum)
Dim nCountFile As Integer
For nCountFile = 1 To vFileNum
If strPath(nCountFile) = "False" Then
Exit Sub
End If
Next nCountFile
Application.DisplayAlerts = False
For nCountFile = 1 To vFileNum
Workbooks(strBookName(nCountFile)).Activate
Dim sht As Worksheet
For Each sht In Worksheets
sht.[D7] = 1
Next
Workbooks(strBookName(nCountFile)).Close True
Next nCountFile
Application.DisplayAlerts = True
MsgBox "完成!", vbInformation
End Sub
我的个性签名