C
carlo
Hello All
IMO this is a strange behaviour.
I created an Add-In which manipulates data, deletes all sheets, except
one, then stores it in 2 different folders with SaveCopyAs.
Now, when I open the saved files, the sheetname (of the only Sheet in
the file) has changed to the name of the Workbook.
here's my code: (I left out the data manipulating part and the sheet
deletion, because it happens during saving)
Private Sub Backup_process()
'copy this sheet to a specified destination for backup purposes
'the windows script host object model has to be referenced in order to
succeed.
'--> go to Tools->References and check "windows script host object
model"
Dim objFSO As FileSystemObject
Dim strDestfolder As String
Dim strNewFileName As String
Dim arr_path As Variant
Dim str_path As String
Set objFSO = New FileSystemObject
FName = "C:\"
ActiveWorkbook.SaveCopyAs FName & "Data\LinkVC.xls"
strDestfolder = FName & "Backup\" & Format(Now(), "yyyymm")
strNewFileName = "LinkVC_" & Format(Now(), "yyyymmddhhmmss") & ".xls"
If Not objFSO.FolderExists(strDestfolder) Then
arr_path = Split(strDestfolder, "\")
For Each path_ In arr_path
str_path = str_path & path_ & "\"
If Not objFSO.FolderExists(str_path) Then
MkDir (str_path)
End If
Next path_
End If
ActiveWorkbook.SaveCopyAs strDestfolder & "\" & strNewFileName
End Sub
Does that make sense to any of you?
Appreciate any thoughts.
Thanks in advance
Carlo
IMO this is a strange behaviour.
I created an Add-In which manipulates data, deletes all sheets, except
one, then stores it in 2 different folders with SaveCopyAs.
Now, when I open the saved files, the sheetname (of the only Sheet in
the file) has changed to the name of the Workbook.
here's my code: (I left out the data manipulating part and the sheet
deletion, because it happens during saving)
Private Sub Backup_process()
'copy this sheet to a specified destination for backup purposes
'the windows script host object model has to be referenced in order to
succeed.
'--> go to Tools->References and check "windows script host object
model"
Dim objFSO As FileSystemObject
Dim strDestfolder As String
Dim strNewFileName As String
Dim arr_path As Variant
Dim str_path As String
Set objFSO = New FileSystemObject
FName = "C:\"
ActiveWorkbook.SaveCopyAs FName & "Data\LinkVC.xls"
strDestfolder = FName & "Backup\" & Format(Now(), "yyyymm")
strNewFileName = "LinkVC_" & Format(Now(), "yyyymmddhhmmss") & ".xls"
If Not objFSO.FolderExists(strDestfolder) Then
arr_path = Split(strDestfolder, "\")
For Each path_ In arr_path
str_path = str_path & path_ & "\"
If Not objFSO.FolderExists(str_path) Then
MkDir (str_path)
End If
Next path_
End If
ActiveWorkbook.SaveCopyAs strDestfolder & "\" & strNewFileName
End Sub
Does that make sense to any of you?
Appreciate any thoughts.
Thanks in advance
Carlo