ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save file close and reopen (https://www.excelbanter.com/excel-programming/408600-save-file-close-reopen.html)

Graham[_2_]

Save file close and reopen
 
I have a workbook with several procedures which work on other files that I open. ie there
are no procedures within the workbooks that are opened but the "resident" workbook stays
open and contains them all. The files that are opened are csv files which are then edited
using the procedures and re-saved. What I need to do is create a procedure where the csv
file is saved using something like the line below to open the save-as window so the user
can choose a file name, then I need to close the csv file, open exactly the same file
again and save it, leaving the file open this time. Thus in short, save csv file, close
file, open same file and save it again. I no this sounds a bit convoluted but
unfortunately it is necessary. After the save as I have got lost on how close and open the
same file again and save I would value any guidance.

Application.GetSaveAsFilename ("*.csv")

Kind Regards,

Graham
Turriff
Scotland

Per Jessen

Save file close and reopen
 
Hi Graham

Try this

Dim MyFileName As String
MyFileName = Application.GetSaveAsFilename(fileFilter:=".csv (*.csv),
*.csv")
ActiveWorkbook.SaveAs (MyFileName)
ActiveWorkbook.Close
Workbooks.Open (MyFileName)
ActiveWorkbook.Save

Regards,

Per

"Graham" skrev i meddelelsen
...
I have a workbook with several procedures which work on other files that I
open. ie there are no procedures within the workbooks that are opened but
the "resident" workbook stays open and contains them all. The files that
are opened are csv files which are then edited using the procedures and
re-saved. What I need to do is create a procedure where the csv file is
saved using something like the line below to open the save-as window so the
user can choose a file name, then I need to close the csv file, open
exactly the same file again and save it, leaving the file open this time.
Thus in short, save csv file, close file, open same file and save it again.
I no this sounds a bit convoluted but unfortunately it is necessary. After
the save as I have got lost on how close and open the same file again and
save I would value any guidance.

Application.GetSaveAsFilename ("*.csv")

Kind Regards,

Graham
Turriff
Scotland



Graham[_2_]

Save file close and reopen
 
Many thanks for that Per, I really appreciate the help

Kind regards
Graham

Per Jessen wrote:
Hi Graham

Try this

Dim MyFileName As String
MyFileName = Application.GetSaveAsFilename(fileFilter:=".csv (*.csv),
*.csv")
ActiveWorkbook.SaveAs (MyFileName)
ActiveWorkbook.Close
Workbooks.Open (MyFileName)
ActiveWorkbook.Save

Regards,

Per

"Graham" skrev i meddelelsen
...
I have a workbook with several procedures which work on other files
that I open. ie there are no procedures within the workbooks that are
opened but the "resident" workbook stays open and contains them all.
The files that are opened are csv files which are then edited using
the procedures and re-saved. What I need to do is create a procedure
where the csv file is saved using something like the line below to
open the save-as window so the user can choose a file name, then I
need to close the csv file, open exactly the same file again and save
it, leaving the file open this time. Thus in short, save csv file,
close file, open same file and save it again. I no this sounds a bit
convoluted but unfortunately it is necessary. After the save as I have
got lost on how close and open the same file again and save I would
value any guidance.

Application.GetSaveAsFilename ("*.csv")

Kind Regards,

Graham
Turriff
Scotland



Per Jessen

Save file close and reopen
 
Hi Graham

Thanks for your reply.

Best regards
Per

"Graham" skrev i meddelelsen
...
Many thanks for that Per, I really appreciate the help

Kind regards
Graham




All times are GMT +1. The time now is 11:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com