Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following macro assigned to a button to allow the user to make a
backup copy in the current folder (example: Backup_Username.xls). Works OK, but sometimes (I haven't figured out under what circumstances) a copy turns up in XLSTART as well. And then of course that copy opens next time the user launches his file, which is a nuisance. Don't know how to prevent that happening. Sub Backupbutton() 'Creates backup copy of user's file, in same folder Dim usrfile As Workbook Dim backname As String Set usrfile = ActiveWorkbook path = ActiveWorkbook.path backname = path & "\" & "Backup_" & usrfile.Name usrfile.SaveCopyAs filename:=backname End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe you could check to see if XLStart is part of the Path.
Dim myPath As String ' I wouldn't use a variable named Path. myPath = ActiveWorkbook.Path If InStr(1, myPath, "\xlstart", vbTextCompare) = 0 Then 'do the save Else 'skip it End If Andyjim wrote: I have the following macro assigned to a button to allow the user to make a backup copy in the current folder (example: Backup_Username.xls). Works OK, but sometimes (I haven't figured out under what circumstances) a copy turns up in XLSTART as well. And then of course that copy opens next time the user launches his file, which is a nuisance. Don't know how to prevent that happening. Sub Backupbutton() 'Creates backup copy of user's file, in same folder Dim usrfile As Workbook Dim backname As String Set usrfile = ActiveWorkbook path = ActiveWorkbook.path backname = path & "\" & "Backup_" & usrfile.Name usrfile.SaveCopyAs filename:=backname End Sub -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Dave,
I changed the code thus: Dim usrfile As Workbook Dim backname As String Set usrfile = ActiveWorkbook Dim p As String p = ActiveWorkbook.path backname = p & "\" & "Backup_" & usrfile.Name If InStr(1, p, "xlstart", vbTextCompare) = 0 Then usrfile.SaveCopyAs filename:=backname Else 'do nothing End If It hasn't put a copy in XLSTART since, but then neither has another file using the previous code. I still have no clue under what circumstances it does put a copy in XLSTART (it's been inconsistent best I could tell), so unfortunately I don't know whether it's really fixed or not. Best I can do is go with it until proven wrong. If you have ideas why a copy should ever show up in XLSTART, I'd at least feel better... |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It looked like you had a file by the name of UserName.xls in that XLStart folder
(from the original post, anyway). Andyjim wrote: Thanks Dave, I changed the code thus: Dim usrfile As Workbook Dim backname As String Set usrfile = ActiveWorkbook Dim p As String p = ActiveWorkbook.path backname = p & "\" & "Backup_" & usrfile.Name If InStr(1, p, "xlstart", vbTextCompare) = 0 Then usrfile.SaveCopyAs filename:=backname Else 'do nothing End If It hasn't put a copy in XLSTART since, but then neither has another file using the previous code. I still have no clue under what circumstances it does put a copy in XLSTART (it's been inconsistent best I could tell), so unfortunately I don't know whether it's really fixed or not. Best I can do is go with it until proven wrong. If you have ideas why a copy should ever show up in XLSTART, I'd at least feel better... -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, just meant that as an example of the format of the resulting filename. I
will not know what name the user gives the file. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you know the name of the backup file that you found in XLStart, then it
should be easy to check to see if the original file is in that same XLStart folder. If you're saying that there wasn't a file in the XLStart folder, but there was still a backup_xxxx.xls created, then I don't have a guess. Andyjim wrote: No, just meant that as an example of the format of the resulting filename. I will not know what name the user gives the file. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Turn off auto backup copy | Excel Worksheet Functions | |||
backup copy of a workbook | Excel Discussion (Misc queries) | |||
backup copy of a workbook | Excel Discussion (Misc queries) | |||
Automatic backup copy | Charts and Charting in Excel | |||
Copy for Backup Purpose. | Excel Programming |