Word VBA 获取 Project is Unviewable 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23821295/
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
Word VBA getting Project is Unviewable error
提问by user3463768
When I try to edit or step into my VBA code for debugging purpose I get "Project is Unviewable". I have created .dotm file at location (C:\Users\UserName\AppData\Roaming\Microsoft\Word\STARTUP).
当我尝试编辑或进入我的 VBA 代码进行调试时,我得到“项目无法查看”。我在位置 (C:\Users\UserName\AppData\Roaming\Microsoft\Word\STARTUP) 创建了 .dotm 文件。
回答by Malcolm McCaffery
When launched automatically at startup the VBA project in .DOTM files are not viewable. I couldn't find this clearly documented by Microsoft but I tested/replicated it across multiple OS and versions of Office to conclude it was "by design"
在启动时自动启动时,.DOTM 文件中的 VBA 项目不可见。我找不到微软明确记录的这一点,但我在多个操作系统和 Office 版本中测试/复制了它,得出结论它是“设计使然”
There is some ways around it:
有一些方法可以解决它:
Option #1
选项1
Copy template OUT of Start Up Folder, right click file and select "Open" You can debug it.
将模板复制到启动文件夹中,右键单击文件并选择“打开”即可调试。
Option #2
选项#2
Ensure you have write permission to file in startup folder. Even if you are Admin, if UAC is ON you won't have access - grant your user "full control" or "write access to file" to DOTM file in startup folder.
确保您对启动文件夹中的文件具有写权限。即使您是管理员,如果 UAC 处于开启状态,您将无权访问 - 授予您的用户对启动文件夹中的 DOTM 文件的“完全控制权”或“对文件的写入访问权”。
Close all instances of Word, right click .DOTM file and Open, you can now debug it.
关闭所有 Word 实例,右键单击 .DOTM 文件并打开,您现在可以对其进行调试。
However you can't save changes - to save changes you must grant permissions for the user to write to the STARTUP folder.
但是,您无法保存更改 - 要保存更改,您必须授予用户写入 STARTUP 文件夹的权限。
回答by Rashid Khan
this is not a bug. This is a feature of Microsoft Templates when you open a template it never opens original file rather opens a copy of the template. to modify or debug a template right click on template itself and say open or open word and use Open file dialog to modify the code of the template.
这不是错误。这是 Microsoft 模板的一项功能,当您打开模板时,它永远不会打开原始文件,而是打开模板的副本。修改或调试模板右键单击模板本身并说打开或打开单词并使用打开文件对话框来修改模板的代码。
回答by nicname
Open the .dotm from .../STARTUP location and do modifications and saves there.
从 .../STARTUP 位置打开 .dotm 并在那里进行修改和保存。
回答by iaforek
回答by CODE-REaD
To expand on https://stackoverflow.com/a/39171282/5025060, in my case (Windows 7 Pro, MS Word 2007), left-clicking on a .dot file from Windows File Explorer (Win+E) causes MS Word to create a new document(namedDocument5
in my case). The macros from the .dot file I opened are active inDocument5
, but when I attempt to edit these macros (MS Word Developer tab, Macros button, Edit button) this message pops up:
要扩展https://stackoverflow.com/a/39171282/5025060,在我的情况下(Windows 7 Pro,MS Word 2007),左键单击来自 Windows 文件资源管理器 ( Win+ E)的 .dot 文件会导致 MS Word创建一个新文档(Document5
在我的例子中命名)。我打开的 .dot 文件中的宏在Document5
.
However, if I right-click on the .dot file from Windows File Explorer, select Open With, and choose Microsoft Office Wordfrom File Explorer's menu, MS Word opens the file for editingrather than creating a new Document (the name in Word's Title Bar is that of the .dot file I opened). From this instance of Word I can view and edit the macros contained in the .dot file.
但是,如果我在 Windows 文件资源管理器中右键单击 .dot 文件,选择打开方式,然后从文件资源管理器的菜单中选择Microsoft Office Word,MS Word 会打开该文件进行编辑,而不是创建一个新文档(Word 标题中的名称) Bar 是我打开的 .dot 文件的那个)。从这个 Word 实例中,我可以查看和编辑 .dot 文件中包含的宏。
回答by Lakhan Mane
Go to Review > share workbook > Editing > disable the checkbox
转到查看 > 共享工作簿 > 编辑 > 禁用复选框
回答by Christopher Peisert
Update 2020
2020 年更新
When editing macro-enabled Word documents (for example, .docm
files) that are stored on OneDrive, you may receive the following warning:
编辑.docm
存储在 OneDrive 上的启用宏的 Word 文档(例如文件)时,您可能会收到以下警告:
SECURITY WARNING Macros have been disabled. Enabled Content
安全警告宏已被禁用。 Enabled Content
After clicking Enabled Content, and opening the VBA editor, attempting to view the project may result in the error:
Project is unviewable
单击 后Enabled Content,打开 VBA 编辑器,尝试查看项目可能会导致错误:
项目无法查看
After closing and reopening the document, again open the VBA editor. Within the Word document, you will then receive the following message:
关闭并重新打开文档后,再次打开 VBA 编辑器。在 Word 文档中,您将收到以下消息:
EDITING MACROS Check out this document to view and edit its macros. Check Out
编辑宏 查看此文档以查看和编辑其宏。 Check Out
After checking out out the document, the macros may be editing.
签出文档后,宏可能正在编辑。
回答by Domestosi
For editing VBA you have to go to Review/Share workbook. Need to disable checkbox.
要编辑 VBA,您必须转到查看/共享工作簿。需要禁用复选框。
Good luck =)
祝你好运=)