在Excel 2010中更改“另存为”对话框的默认路径 [英] Change the default path of the SaveAs dialog in Excel 2010

查看:340
本文介绍了在Excel 2010中更改“另存为”对话框的默认路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我有一些驻留在服务器上的Excel(2010)电子表格。

每个都有属性'只读'设置。显然,这不允许用户保存(覆盖)原始副本。



然而,我的问题是我希望用户将副本保存到他们的我的文档在驱动器C:。



我查看了Workbook_BeforeSave事件,但不知道如何更改默认路径。



可以有人建议是否以及如何做到这一点。



提前致谢。



Darrell

Hi everyone

I have a number of Excel(2010) spreadsheets that reside on a server.
Each of these have the property 'Read-Only' set. This, obviously, disallows the user from saving(overriding) the original copy.

My problem, however, is that I want the users to save a copy to their "My Documents" on drive C:.

I have looked at the Workbook_BeforeSave event but have no idea of how to change the default path.

Could anyone suggest if and how this could be done.

Thanks in advance.

Darrell

推荐答案

最简单的方法是使用 Environ ChDrive ChDir 功能。



The simplest way is to use Environ, ChDrive and ChDir function.

Dim sUserPath As String, sDefaultPath

sDefaultPath = Application.DefaultFilePath
sUserPath = Environ("USERPROFILE") & "My Documents\" 

'first method:
'ChDrive sUserPath
'ChDrir sUserPath

'second method
Application.DefaultFilePath = sUserPath

'your code here

'restore default path
Application.DefaultFilePath = sDefaultPath





如何使用其他方法获取 MyDocuments 文件夹?请参阅:获取我的文档路径VBA [ ^ ]



How to get MyDocuments folder using other methods? Please, see: Get the Path to My Documents in VBA[^]


这篇关于在Excel 2010中更改“另存为”对话框的默认路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆