|
在设备xp系统上能运行,版本是2007(12.0.6214.1000) SP1 MSO(12.0.6213.1000),在另一台电脑上则运行到选择文件夹后就没反应了,另一台电脑是win7系统,excel版本是2007(12.0.6214.1000)SP1 MSO(12.0.6514.5000),请高手指点是系统的原因还是版本的原因,或如何修改代码使得可以在win7上也能运行,具体代码如下,望指点。
Sub 签名()
'
' 签名 Macro
Dim myDialog As FileDialog, oFile As Object, strName As String, n As Integer
Dim FSO As Object, myFolder As Object, myFiles As Object
Dim fn$
Dim Ra As Range
Set myDialog = Application.FileDialog(msoFileDialogFolderPicker)
n = 1
With myDialog
If .Show <> -1 Then Exit Sub
Set FSO = CreateObject("Scripting.FileSystemObject") '这是文件夹选择,点选到你存放文件的那个
Set myFolder = FSO.GetFolder(.InitialFileName)
Set myFiles = myFolder.Files
For Each oFile In myFiles
strName = UCase(oFile.Name)
strName = VBA.Right(strName, 3)
If strName = "xls" Or strName = "XLS" Then
'这是扩展名选择 '下面就可接着写打开文件读取数据再写入的语句了,如下:
fn = myFolder & "\" & oFile.Name
Workbooks.Open Filename:=fn
For Each Ra In Range("A1:AZ" & Range("b65536").End(xlUp).Row)
Select Case Ra.Value
Case "填表人:"
Ra.Value = "填表人:高峰"
Case "复核人:"
Ra.Value = "复核人:英仓"
Case "负责人:"
Ra.Value = "负责人:贤军"
End Select
Next
ActiveWindow.Close (True)
End If
Next
End With
'
End Sub
|
|