ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Saving xls in specific directory (https://www.excelbanter.com/excel-programming/376986-saving-xls-specific-directory.html)

David Hodgson

Saving xls in specific directory
 
Hi folks,

Is there a way to open an excell file so that when you go to save it it
saves in a specific directory?

ps I am opening this file using the hyperlink function within excel.

thanks
Dave


Alan

Saving xls in specific directory
 
Dave, do you want to save the file in the same directory it was opened
from or to a standard, default directory or to a directory that the
user chooses?

Alan

David Hodgson wrote:
Hi folks,

Is there a way to open an excell file so that when you go to save it it
saves in a specific directory?

ps I am opening this file using the hyperlink function within excel.

thanks
Dave



David Hodgson

Saving xls in specific directory
 
Hi alan,

If the hyperlink points to c:\folderA\test.xls, I want excel to save it
in c:\folderB\test.xls. But I only want this to happen for test.xls.

Dave

Alan wrote:
Dave, do you want to save the file in the same directory it was opened
from or to a standard, default directory or to a directory that the
user chooses?

Alan

David Hodgson wrote:
Hi folks,

Is there a way to open an excell file so that when you go to save it it
saves in a specific directory?

ps I am opening this file using the hyperlink function within excel.

thanks
Dave



Bob Phillips

Saving xls in specific directory
 
Trap the BeforeSave event and write it to your specified directory

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
Application.DisplayAlerts = False
ThisWorkbook.SaveAs "C:\myDir\" & ThisWorkbook.Name
Application.DisplayAlerts = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"David Hodgson" wrote in message
ps.com...
Hi folks,

Is there a way to open an excell file so that when you go to save it it
saves in a specific directory?

ps I am opening this file using the hyperlink function within excel.

thanks
Dave




Alan

Saving xls in specific directory
 
Dave, the only thing that you may want to add to Bob's code is a test
that you are saving "test.xls" and not another file. Hence ...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
If ThisWorkbook.Name = "test.xls" Then
Application.DisplayAlerts = False
ThisWorkbook.SaveAs "C:\myDir\" & ThisWorkbook.Name
Application.DisplayAlerts = True
End If
End Sub

Bob Phillips wrote:
Trap the BeforeSave event and write it to your specified directory

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True
Application.DisplayAlerts = False
ThisWorkbook.SaveAs "C:\myDir\" & ThisWorkbook.Name
Application.DisplayAlerts = True
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"David Hodgson" wrote in message
ps.com...
Hi folks,

Is there a way to open an excell file so that when you go to save it it
saves in a specific directory?

ps I am opening this file using the hyperlink function within excel.

thanks
Dave




All times are GMT +1. The time now is 08:27 AM.

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