vba VB6 Excel.Application 对象“权限被拒绝”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10619805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VB6 Excel.Application Object "Permission Denied"
提问by Gabriel
I am giving up, will send everything to an XLS VBA. Thanks!
我放弃了,将所有内容发送到 XLS VBA。谢谢!
I am having to add a small modification to a VB6 program on a Win7 and Office2010 (v14.0 32bits) environment. Currently the program tries to instantiate by the following line of code:
我不得不在 Win7 和 Office2010 (v14.0 32bits) 环境中对 VB6 程序添加一个小的修改。目前该程序尝试通过以下代码行实例化:
Dim objExcel as Excel.Application
Set objExcel = New Excel.Application
Right after executing the 2nd line of code, I am showed the error 70: Permission Denied. I have tried a simple test on an Excel VBA, for the same line of code, and works great.
在执行第二行代码后,我立即显示错误 70:权限被拒绝。我已经在 Excel VBA 上针对同一行代码尝试了一个简单的测试,并且效果很好。
Any clues? is it possible that a service that should be running is down? Anything I should do to avoid reinstalling Office?
有什么线索吗?应该运行的服务是否可能已关闭?我应该做些什么来避免重新安装 Office?
Hints I have collected:
我收集的提示:
Have tried to config permissions on DCOMCNFG but wasn't able to find the Excel Application.
Have tried to run excel.exe /regserver but nothing to seems to happen: Excel runs as usual when it is supposed to run silently.
Ran ProcessMonitor and found that a call to
Excel.exe \automation
showedPath Not Found
(I have checked the path, is ok, I guess the\automation
is bothering around).If I change the code to instantiate a Word Application (and of course dll references), same error appears.
Full permissions given to Office14 folder. Img in follwing link: http://i.stack.imgur.com/sgZW5.png(Sorry, as new user, can't post images)
已尝试在 DCOMCNFG 上配置权限,但无法找到 Excel 应用程序。
已尝试运行 excel.exe /regserver 但似乎没有任何反应:Excel 在应该静默运行时照常运行。
运行 ProcessMonitor 并发现调用
Excel.exe \automation
显示Path Not Found
(我已经检查了路径,没问题,我猜\automation
是在打扰)。如果我更改代码以实例化 Word 应用程序(当然还有 dll 引用),则会出现相同的错误。
授予 Office14 文件夹的完全权限。img 在以下链接中:http: //i.stack.imgur.com/sgZW5.png(抱歉,作为新用户,无法发布图片)
Thanks in advance.
提前致谢。
Gabriel
加布里埃尔
回答by Michal Kadlec
I have facing similar problem, I am using in my access DB VBA for opening excel files and therefore I am using command "Set xlApp = CreateObject("Excel.Application")", which suddenly one day starts to throw error 70 Access denied and before it worked fine for couple of months. I start to google it and the moment I learned that it is DCOM error I realized the source of the problems. Because few days ago I was trying to connect my PC with OPC client installed to OPC server and it required to change my local default DCOM setting, I needed to change the default authentification level. So the resolution of my problem was:
我遇到了类似的问题,我在访问 DB VBA 中使用打开 excel 文件,因此我使用命令“Set xlApp = CreateObject("Excel.Application")”,突然有一天开始抛出错误 70 Access denied 和在它工作了几个月之前。我开始用谷歌搜索它,当我得知这是 DCOM 错误时,我意识到了问题的根源。因为几天前我试图将装有 OPC 客户端的 PC 连接到 OPC 服务器,并且需要更改我本地的默认 DCOM 设置,所以我需要更改默认的身份验证级别。所以我的问题的解决方案是:
run command dcomcnfg in command line
go to Console root > Component Services > Computers > My Computer > DCOM config > Microsof Excel Application
right clic and select properties
In the general tab change the Authentification Level to "None"
在命令行中运行命令 dcomcnfg
转到控制台根目录 > 组件服务 > 计算机 > 我的电脑 > DCOM 配置 > Microsof Excel 应用程序
右键单击并选择属性
在常规选项卡中,将身份验证级别更改为“无”
and tats it
和它
回答by Siddharth Rout
Try this
尝试这个
1) Open Windows Explorer and navigate to C:\Program Files (x86)\Microsoft Office
1) 打开 Windows 资源管理器并导航到 C:\Program Files (x86)\Microsoft Office
3) Right click on the folder "Office14" and click on "Properties"
3) 右键单击文件夹“Office14”,然后单击“属性”
4) Navigate to the "Security" Tab
4)导航到“安全”选项卡
5) Give "Full Control" to [Machine]\Users.
5) 将“完全控制”授予 [Machine]\Users。
6) Now Try running your vb6 App again
6)现在尝试再次运行您的 vb6 应用程序
回答by Bhatti
In DCOM CONFIG try setting the following:
在 DCOM CONFIG 中尝试设置以下内容:
- General Tab -> Authentication Level -> None
- Identity Tab -> select 'the interactive user'
- 常规选项卡 -> 身份验证级别 -> 无
- 身份选项卡 -> 选择“交互式用户”
hope this helps
希望这可以帮助
回答by Bob77
Have you checked your DCOM defaultsecurity settings on the machine? These are in the Properties of "My Computer" in the Component Services MMC snap-in. You can still get there by running dcomcnfg
.
您是否检查过机器上的DCOM默认安全设置?这些位于组件服务 MMC 管理单元中“我的电脑”的属性中。您仍然可以通过运行到达那里dcomcnfg
。
回答by T. Fabre
It just struck me : from your screenshots, it seems you are running Office 32 bits on a 64bits Windows.
这让我震惊:从您的屏幕截图来看,您似乎在 64 位 Windows 上运行 Office 32 位。
So by default, when you open up DCOMCNFG.exe, you access the 64bits version. Which allows you to edit 64bits COM components. And explains why you can't find Excel in there, since Excel is running in WoW64.
所以默认情况下,当您打开 DCOMCNFG.exe 时,您访问的是 64 位版本。它允许您编辑 64 位 COM 组件。并解释了为什么在那里找不到 Excel,因为 Excel 在 WoW64 中运行。
You should try the following command :
您应该尝试以下命令:
C:\Windows\System32\mmc.exe comexp.msc /32
To open the 32bits console. From there you should find settings for Excel's COM component, and edit its permissions. Allow access to everyone, and try running your program again. If that works, you shouldfine tune your permissions afterwords to allow only specific users (allowing DCOM access to everyone IS dangerous...).
打开32位控制台。从那里您应该找到 Excel 的 COM 组件的设置,并编辑其权限。允许所有人访问,然后再次尝试运行您的程序。如果可行,您应该微调您的权限后记以仅允许特定用户(允许 DCOM 访问每个人是危险的...)。
Hope that helps.
希望有帮助。