VBA启用编辑 [英] VBA to enable editing

查看:335
本文介绍了VBA启用编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从安全站点下载附件并使用VBA打开它.

I'm trying to download an attachment from a secured site and open it using VBA.

当我尝试激活工作簿($ workbook(Wb_name).Activate)时,它会引发一些错误,当我单击启用手动编辑并尝试执行相同的代码时,它会很好地工作.

While i'm trying to activate the workbook ( $workbook(Wb_name).Activate ), it throws some error and when I click on enable editing manually and try executing the same code it works fine.

是否有一种方法可以在激活工作簿之前从受保护的视图启用它.

Is there a way to enable the workbook from protected view before activating it.

注意:我已经从网页中提取了文件名.因此,不必为"Wb_name"而烦恼.

Note : I have extracted the file name from the webpage. So don't have to bother about "Wb_name".

推荐答案

一种可能性是在打开Excel工作簿之前,以编程方式将宏安全设置更改为最低设置.处理完数据后,重新启用宏安全性的先前设置

One possibility is to change the macro security settings programmatically to the lowest before you open the Excel workbook. After manipulating your data, re-enable the previous setting of the macro security

Public Sub MySubroutine()
Dim lSecurity As Long

lSecurity = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityLow

'''''''''''''''''''''
'   Run code here   '
'''''''''''''''''''''

Application.AutomationSecurity = lSecurity

结束子

链接也可能对您有帮助.

this link may also help you..

这篇关于VBA启用编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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