如何以编程方式重新启用 MS Office 禁用文件列表中的文档

发布于 2024-07-17 06:43:49 字数 248 浏览 3 评论 0原文

MS Office 程序保留了以前打开时导致错误的禁用文件的列表。 用户可以通过程序菜单访问该列表并选择要重新启用的文档,从而从此列表中删除文档。 (http://support.microsoft.com/kb/286017

问题是: 如何在不与 GUI 交互的情况下以编程方式完成文档的重新启用?

MS Office programs keep a list of disabled files that have caused errors when previously opened. A user can remove documents from this list by accessing the list through the program menu and selecting a document to be re-enabled. (http://support.microsoft.com/kb/286017)

The question is: How can this re-enabling of documents be accomplished programmatically, without interaction with the gui?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

温柔戏命师 2024-07-24 06:43:49

整合之前的答案并在这里进行阐述。

Office 产品将禁用的项目存储在注册表中名为 HKEY_CURRENT_USER\Software\Microsoft\Office\\\Resiliency\DisabledItems 的项下。 例如,Excel 2010 的禁用列表位于 HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Resiliency\DisabledItems 下。

每个禁用的项目都存储为 REG_BINARY 类型的随机命名键。 字节数组的格式为:

  • 字节0-3:??? (可能是 32 位 uint 类型代码,1 = COM Addin)
  • 字节 4-7:第一个字符串(路径)的 32 位 uint 长度(以字节为单位)
  • 字节 8-11:32 位 uint 长度(以字节为单位)对于第二个字符串(描述)
  • 字节12-end:两个unicode字符字符串,每个字符串的字节长度存储在上面的uint中

Consolidating previous answers and expounding upon them here.

Office products store disabled items in the registry under keys named HKEY_CURRENT_USER\Software\Microsoft\Office\<version>\<product>\Resiliency\DisabledItems. For example, Excel 2010's disabled list is under HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Excel\Resiliency\DisabledItems.

Each disabled item is stored as a randomly-named key of type REG_BINARY. The format of the byte array is:

  • bytes 0-3 : ??? (perhaps a 32-bit uint type code, 1 = COM Addin)
  • bytes 4-7 : 32-bit uint length (in bytes) for the first string (path)
  • bytes 8-11 : 32-bit uint length (in bytes) for the second string (description)
  • bytes 12-end : two strings of unicode characters, the byte length for each of which is stored in the uints above
缱倦旧时光 2024-07-24 06:43:49

用于重新启用 Excel 2016 中所有“禁用项目”的 BAT 脚本。
禁用项目可在 Excel->文件->选项->插件->管理->禁用项目中找到。

:: Deletes all values under the key.  
REG DELETE HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Resiliency\DisabledItems /va /f 

仅供参考:
/va 删除该键下的所有值。
/f 强制删除而不提示。

附言。 我有一堆使用任务计划程序运行宏的工作簿。 Excel 会随机添加崩溃到禁用项目列表中的工作簿。 所以每天运行这个BAT脚本就可以解决问题了。

BAT script to re-enable all "disabled items" in Excel 2016.
Disabled items are found in Excel->File->Options->Addins->Manage->Disabled items.

:: Deletes all values under the key.  
REG DELETE HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Resiliency\DisabledItems /va /f 

Fyi on params:
/va Delete all values under this key.
/f Forces the deletion without prompt.

PS. I have a bunch of workbooks that run macros with a task scheduler. Excel would randomly add workbooks that crashed onto the disabled items list. So running this BAT script daily resolves it OK.

扶醉桌前 2024-07-24 06:43:49

这是我整理的一个 Powershell 脚本,用于解决我在 Win7 上使用 MS-Access 2013 时遇到的类似问题

#RemoveOfficeDisabledItem.ps1
#command line: 
#   powershell -executionpolicy unrestricted -file ".\RemoveOfficeDisabledItem.ps1"

#Update these variables to suit your situation
$OfficeVersion="15.0"
$OfficeApp="Access"
$FileName="My Blocked File.mdb"

#Converts the File Name string to UTF16 Hex
$FileName_UniHex=""
[System.Text.Encoding]::ASCII.GetBytes($FileName.ToLower()) | %{$FileName_UniHex+="{0:X2}00" -f $_}

#Tests to see if the Disabled items registry key exists
$RegKey=(gi "HKCU:\Software\Microsoft\Office\${OfficeVersion}\${OfficeApp}\Resiliency\DisabledItems\")
if($RegKey -eq $NULL){exit}

#Cycles through all the properties and deletes it if it contains the file name.
foreach ($prop in $RegKey.Property) {
   $Val=""
   ($RegKey|gp).$prop | %{$Val+="{0:X2}" -f $_}
   if($Val.Contains($FileName_UniHex)){$RegKey|Remove-ItemProperty -name $prop}
}

Here is a Powershell Script that I threw together to fit a similar problem I was having with MS-Access 2013 on Win7

#RemoveOfficeDisabledItem.ps1
#command line: 
#   powershell -executionpolicy unrestricted -file ".\RemoveOfficeDisabledItem.ps1"

#Update these variables to suit your situation
$OfficeVersion="15.0"
$OfficeApp="Access"
$FileName="My Blocked File.mdb"

#Converts the File Name string to UTF16 Hex
$FileName_UniHex=""
[System.Text.Encoding]::ASCII.GetBytes($FileName.ToLower()) | %{$FileName_UniHex+="{0:X2}00" -f $_}

#Tests to see if the Disabled items registry key exists
$RegKey=(gi "HKCU:\Software\Microsoft\Office\${OfficeVersion}\${OfficeApp}\Resiliency\DisabledItems\")
if($RegKey -eq $NULL){exit}

#Cycles through all the properties and deletes it if it contains the file name.
foreach ($prop in $RegKey.Property) {
   $Val=""
   ($RegKey|gp).$prop | %{$Val+="{0:X2}" -f $_}
   if($Val.Contains($FileName_UniHex)){$RegKey|Remove-ItemProperty -name $prop}
}
猥︴琐丶欲为 2024-07-24 06:43:49

对于 MS Office XP (2002) MSWord,禁用文档列表以随机命名的二进制值形式保存在以下键下:
[HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Word\Resiliency\DisabledItems]

因此,删除每个用户的“DisabledItems”键下的值可能会成功。

还有更多的事情吗? 我还不知道。

Regarding MS Office XP (2002) MSWord the list of disabled documents is kept as randomly named binary values under the key:
[HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Word\Resiliency\DisabledItems]

So deleting the values under the "DisabledItems" key for every user probably will do the trick.

Is there something more to it? I don't know - yet.

情归归情 2024-07-24 06:43:49

有一篇关于 Office 如何处理 COMAddins 的好文章,位于 codeproject。 普通插件得到同等处理,并且系统到目前为止保持不变(直到 Office 2013)。
据我所知。 随机命名的值包含一个由 NULL 字符串分隔的 unicode 字符的字节数组。
我无法找到以空分隔的值数组中的所有条目。 但是,索引 (3) 包含 ADDIn 的文件名,索引 (4) 包含 ADDIn 的描述(如果可用)。

因此,正如 Luie 在 2009 年所写的那样,在删除注册表项之前,应该读取这些值并要求用户重新安装插件。

There is a good article about how Office handles COMAddins at codeproject. Normal Addins are handled equally and the system was kept unchanged so far (up to Office 2013).
As far as I found out. The randomly named value contains a byte-array of unicode characters, separated by null-strings.
I could not find out about all the entries in the null-separated array of values. However index (3) contains the filename of the ADDIn and index (4) contains a description of the ADDIn if available.

So one should read the values and ask the user to reinstall the addins before deleting the registry keys as Luie wrote back in 2009.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文