vba:如何以编程方式以只读方式打开工作簿? [英] vba: how do i open workbook programmatically as read-only?

查看:691
本文介绍了vba:如何以编程方式以只读方式打开工作簿?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我如何在vbA中打开一个excel文件:

  Workbooks.Open(file-path)$ b $有没有一种方法来指定它应该是只读的?文件打开对他们有一个密码,我总是得到只能作为只读打开的对话框。

解决方案

这是否工作?

  Workbooks.Open文件名:= filepath,ReadOnly:= True 

或者,中指出,以编程方式只读#comment60139462_3389577>,以保留对打开的工作簿的引用:

  Dim book As Workbook 
Set book = Workbooks.Open(Filename:= filepath,ReadOnly:= True)


this is how i can open an excel file in vbA:

Workbooks.Open(file-path)

is there a way to specify that it should be open as read-only? the files im opening have a password on them and i always get the dialog that it can only be open as read only.

Does this work?

Workbooks.Open Filename:=filepath, ReadOnly:=True

Or, as pointed out in a comment, to keep a reference to the opened workbook:

Dim book As Workbook
Set book = Workbooks.Open(Filename:=filepath, ReadOnly:=True)

这篇关于vba:如何以编程方式以只读方式打开工作簿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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