From: Carrie_Loos via OfficeKB.com on 14 May 2010 19:50 I have a file that I update each day and then it is updated by others. (Not a shared file) Everyday I open and run my code to pull in yesterdays updates. Before I pull in the updates I want to save a copy, "backup" in the same path on the server where the original file is located. I have tried various attempts which seem so simple but they are saving elsewhere...Can anyone direct me on how to write the piece to make sure the file saves where I want it to? Thanks -- Message posted via http://www.officekb.com
From: JLGWhiz on 14 May 2010 20:28 While the workbook you want backup is open and is the active workbook, you can set a variable to its path. myPath = ActiveWorkbook.Path Then use that variable in the SaveAs command as part of the file name. ActiveWorkbook.SaveAs Filename:=myPath & "\<backupname>.xls?" backupname would be the actual name you give to the backup file and the file extension would be based on the format to which you want to save the file. It is better to use the actual workbook name instead of ActiveWorkbook in case that workbook is not active at the time you decide to initiate the path variable or do the saveas. "Carrie_Loos via OfficeKB.com" <u34134(a)uwe> wrote in message news:a803a82e57e9c(a)uwe... >I have a file that I update each day and then it is updated by others. (Not >a > shared file) Everyday I open and run my code to pull in yesterdays > updates. > Before I pull in the updates I want to save a copy, "backup" in the same > path > on the server where the original file is located. I have tried various > attempts which seem so simple but they are saving elsewhere...Can anyone > direct me on how to write the piece to make sure the file saves where I > want > it to? > > Thanks > > -- > Message posted via http://www.officekb.com >
From: Ron de Bruin on 15 May 2010 05:56 Look also at SaveCopyAs This way the original file stay open and your copy is saved where you want -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "JLGWhiz" <JLGWhiz(a)cfl.rr.com> wrote in message news:OmwVKW88KHA.5716(a)TK2MSFTNGP06.phx.gbl... > While the workbook you want backup is open and is the active workbook, you > can set a variable to its path. > > myPath = ActiveWorkbook.Path > > Then use that variable in the SaveAs command as part of the file name. > > ActiveWorkbook.SaveAs Filename:=myPath & "\<backupname>.xls?" > > backupname would be the actual name you give to the backup file and the file > extension would be based on the format to which you want to save the file. > It is better to use the actual workbook name instead of ActiveWorkbook in > case that workbook is not active at the time you decide to initiate the path > variable or do the saveas. > > "Carrie_Loos via OfficeKB.com" <u34134(a)uwe> wrote in message > news:a803a82e57e9c(a)uwe... >>I have a file that I update each day and then it is updated by others. (Not >>a >> shared file) Everyday I open and run my code to pull in yesterdays >> updates. >> Before I pull in the updates I want to save a copy, "backup" in the same >> path >> on the server where the original file is located. I have tried various >> attempts which seem so simple but they are saving elsewhere...Can anyone >> direct me on how to write the piece to make sure the file saves where I >> want >> it to? >> >> Thanks >> >> -- >> Message posted via http://www.officekb.com >> > >
From: Carrie_Loos via OfficeKB.com on 17 May 2010 12:45 Thank you - this is exactly what I needed JLGWhiz wrote: >While the workbook you want backup is open and is the active workbook, you >can set a variable to its path. > >myPath = ActiveWorkbook.Path > >Then use that variable in the SaveAs command as part of the file name. > >ActiveWorkbook.SaveAs Filename:=myPath & "\<backupname>.xls?" > >backupname would be the actual name you give to the backup file and the file >extension would be based on the format to which you want to save the file. >It is better to use the actual workbook name instead of ActiveWorkbook in >case that workbook is not active at the time you decide to initiate the path >variable or do the saveas. > >>I have a file that I update each day and then it is updated by others. (Not >>a >[quoted text clipped - 9 lines] >> >> Thanks -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/excel-programming/201005/1
|
Pages: 1 Prev: Count Unique Combinations Next: Call random UserForm from list |