小编use*_*660的帖子

使用vba name语句进行xls到xlsx的转换会破坏文件

我正在尝试将文件重命名abcd.xlsxyz.xlsx使用以下代码 -

  NumOfAttachments = Range("RecCount").Value
  DestinationFolderPath = Range("destinationfolder").Value
  NewShtName = "Sheet1"

  If NumOfAttachments <> 0 Then
    For X = 0 To NumOfAttachments - 1
      OrigName = Range("Startcell").Offset(X, 1).Value
      NewName = Range("startcell").Offset(X, 2).Value
      SourceFolderPath = Range("startcell").Offset(X, 3).Value
      NewFile = DestinationFolderPath & NewName
      If Dir(DestinationFolderPath & OrigName) <> "" Then Kill DestinationFolderPath & OrigName
      FileCopy SourceFolderPath & OrigName, DestinationFolderPath & OrigName

      If Dir(NewFile) <> "" Then Kill NewFile
      Name DestinationFolderPath & OrigName As NewFile
Run Code Online (Sandbox Code Playgroud)

在此之后,当我尝试打开文件(xyz.xlsx)时,我收到以下错误 - …

excel vba rename corrupt excel-vba

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

corrupt ×1

excel ×1

excel-vba ×1

rename ×1

vba ×1