Excel 2013自动化界面更改导致无法通过UI进行编辑 [英] Excel 2013 automation interface changes leading to inability to edit through the UI

查看:114
本文介绍了Excel 2013自动化界面更改导致无法通过UI进行编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我最初发布了一个关于Excel 2013自动化界面的问题 - 实际上您回复了(http://social.msdn.microsoft.com/Forums/en -US / officedevpreview / thread / 6e2ba871-ba1d-4bae-b9cd-281559932893)
- 无法看到如何回复您网站上的查询(没有明显的按钮!)

I originally posted a question regarding the Excel 2013 automation interface - in fact you responded (http://social.msdn.microsoft.com/Forums/en-US/officedevpreview/thread/6e2ba871-ba1d-4bae-b9cd-281559932893) - can't see how to reply to a query on your site (no obvious button!)

当我们尝试示例应用程序时,它以与我们自己的应用程序类似的方式执行,即我们只能编辑单元格"A1"。 - 然而,差异可能是您明确选择"A1"。保护工作表,而
我们没有添加保护。

When we tried the example application it performed in a similar manner to our own application i.e. we could only edit cell "A1" - however the difference may be that you are explicitly selecting "A1" and protecting the worksheet whereas we are not adding the protection.

在查找更多信息时,我们似乎无法允许用户编辑工作表可能与我们在创建和填充后离开它的状态。 在我们自己的测试中(所有在VB.NET中)我们创建一个简单的
工作表然后做很少但是观察选择和范围函数有时创建异常(我们还在示例代码中观察到异常)关于范围项目。

In looking for further information it would appear that our inability to allow the user to edit the worksheet could be related to the state in which we leave it after creating and populating.  In our own tests (all in VB.NET) we are creating a simple worksheet and then doing very little but observing that both selection and range functions are at times creating exceptions (we have also observed exceptions in your example code) on range items.

在我们的简单测试中,我们注意到只要选择操作,工作表就不再可以通过用户界面进行编辑

In our simple tests we note that as soon as select operation the worksheet is no longer editable through the user interface

Dim pWorksheet as XL.worksheet = currentXLWorkbook.ActiveSheet

Dim pWorksheet as XL.worksheet = currentXLWorkbook.ActiveSheet

pWorksheet.Cells.Select()

pWorksheet.Cells.Select()

这种选择方法通常会导致异常  - 见图片

It is common for this select method to cause an exception  - see image

我们的应用程序已经运行了一段时间而没有问题,包括2010年的excel,因此非常了解已经做出的导致这种行为改变的变化。

Our application has been running for sometime without issue with excel upto and including 2010 so keen to understand the changes that have been made that would lead to this change of behaviour.


  • 对select和range的行为做了哪些更改?
  • 对依赖项或顺序进行了哪些更改可能会导致此问题
  • 是否有过更改为保护模型?

您可以告知Plase并告诉我们有关excel操作的更多详细信息2013 自动化界面?

Plase can you advise and also point us to more detailed information regarding the operation of the excel 2013 automation interface?

非常感谢

Ian

示例代码中提到的异常示例。

An example of exceptions noted in example code.

System.Runtime.InteropServices.COMException未处理

 消息=来自HRESULT的异常:0x800A01A8

 来源= mscorlib

  ErrorCode = -2146827864

  StackTrace:

       at System.RuntimeType.ForwardCallToInvokeMember(String memberName,BindingFlags flags,Object target,Int32 [] aWrapperTypes,MessageData& msgData)

      在Microsoft.Office.Interop.Excel.Range.set_FormulaHidden(对象值)

       at msdnXL2013example.Form1.Open_Click(Object sender,EventArgs e)位于C:\ Users \\\ documents \ visual studio 2010 \Projects \ msdnXL2013example\msdnXL2013example\Form1.cs:第86行
      在System.Windows.Forms.ToolStripItem.RaiseEvent(Object key,EventArgs e)

      在System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

      在System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

      在System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

       at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e,ToolStripItemEventType met)

      在System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e,ToolStripItemEventType符合)

      在System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

      在System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons按钮,Int32点击)

      在System.Windows.Forms.Control.WndProc(消息& m)

      在System.Windows.Forms.ScrollableControl.WndProc(消息& m)

      在System.Windows.Forms.ToolStrip.WndProc(消息& m)

      在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m)

      在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m)

      在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

      在System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

      在System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID,Int32 reason,Int32 pvLoopData)

       在System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason,ApplicationContext context)

      在System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,ApplicationContext context)

      在System.Windows.Forms.Application.Run(Form mainForm)

       at msdnXL2013example.Program.Main()in C:\ Users\ian\documents\visual studio 2010 \Projects\msdnXL2013example\msdnXL2013example\Program.cs:line 18

      在System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String [] args)

      在System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)

      在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean ignoreSyncCtx)

      在System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)

      在System.Threading.ThreadHelper.ThreadStart()

  InnerException:

System.Runtime.InteropServices.COMException was unhandled
  Message=Exception from HRESULT: 0x800A01A8
  Source=mscorlib
  ErrorCode=-2146827864
  StackTrace:
       at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
       at Microsoft.Office.Interop.Excel.Range.set_FormulaHidden(Object value)
       at msdnXL2013example.Form1.Open_Click(Object sender, EventArgs e) in C:\Users\ian\documents\visual studio 2010\Projects\msdnXL2013example\msdnXL2013example\Form1.cs:line 86
       at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
       at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ToolStrip.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at msdnXL2013example.Program.Main() in C:\Users\ian\documents\visual studio 2010\Projects\msdnXL2013example\msdnXL2013example\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

推荐答案

Hi lan,

Hi lan,

感谢您在MSDN论坛上发帖。

Thanks for posting in the MSDN Forum.

作为您发布的异常消息,当工作表不是活动工作表时会引发该消息。并且0x800A01A8表示"需要对象"。您似乎丢失了Excel范围的参考。并且

As the exception message in you post that will raise when the worksheet isn't an active sheet. And the  0x800A01A8 mean "object required". It seems that you have lost the reference for the Excel Range. And

在查找更多信息时,似乎我们无法允许用户编辑工作表可能与我们在创建和填充之后离开它的状态有关。在我们自己的测试中(所有在VB.NET中)我们创建一个简单的
工作表然后做很少但是观察选择和范围函数有时创建异常(我们还在示例代码中观察到异常)关于范围项目。
In looking for further information it would appear that our inability to allow the user to edit the worksheet could be related to the state in which we leave it after creating and populating. In our own tests (all in VB.NET) we are creating a simple worksheet and then doing very little but observing that both selection and range functions are at times creating exceptions (we have also observed exceptions in your example code) on range items.

请您通过显示您的代码来澄清它吗?我无法满足"我们还在您的示例代码中观察到异常"的情况。在我这边。

Would you please clarify it via show your code? I can't meet the scenario for the "we have also observed exceptions in your example code" on my side.

祝你有个美好的一天,

Tom


这篇关于Excel 2013自动化界面更改导致无法通过UI进行编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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