次のコードabcd.xls
を使用して、ファイルの名前を から に変更しようとしています。xyz.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
xyz.xlsx
この後、ファイル( )を開こうとすると、次のエラーが表示されます-
excel cannot open the file xyz.xlsx because the file format or file extension is not valid