在保存期间使用UDF Excel停止工作之后

我已经设置了一个键盘快捷键( ctrl + alt + c )计算用户select非常基本我抓住了这里

 Private Sub Workbook_Open() Application.OnKey "^%c", "CalculateSelection" End Sub 

 Sub CalculateSelection() On Error GoTo NoSelection If Not Selection Is Nothing Then If TypeName(Application.Selection) = "Range" Then Dim Rng As Range Set Rng = Application.Selection Rng.Calculate End If End If Exit Sub 

NoSelection:MsgBox(“No Range Selected”)End Sub

这在所有其他单元格上都可以很好地工作,并且当它完成时我可以保存我的工作。

如果我在一个调用API的单元上使用这个函数,那么这个函数可以正常工作,直到你保存,微软完全停止工作,我不知道为什么。

有谁知道为什么这可能会发生? 这是否会造成一些物体没有被破坏或是我擅长腐败?

所有的API函数都能正常工作,直到我使用这个子函数为止,我一直没有错误。

这是将数据发送到API的函数。 它具有不同的function,可以从表中调用,将数据格式化为XML,并检查传递的数据是否正确并完全计算。

 Private Function PostToApiXmlToXml(Data As String, Route As String) 'Initialise Document Object Model to hold the XML 'And the xmlHttp to handle Sending Data Dim xmlhttp As MSXML2.ServerXMLHTTP60 Dim XMLDOM As MSXML2.DOMDocument60 Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") Set XMLDOM = New MSXML2.DOMDocument60 'Load entire Document before moving on 'Data is a string but must conatin opening and closing tags. XMLDOM.async = False XMLDOM.LoadXML (Data) 'Using the Http object With xmlhttp Call .setOption(2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS) 'Set up a POST to the Base Address + Route .Open "POST", BaseAddress + Route, False 'Content-Type Header is requred to let the API Know What type of Data you are Sending .setRequestHeader "Content-Type", "application/xml" 'Accept Header Lets the Api know we want to recieve JSON Data .setRequestHeader "Accept", "application/json" 'Send the Dom as XML in the http object .send (XMLDOM.Xml) 'Take in the Response as text PostToApiXmlToXml = .responseText End With Set xmlhttp = Nothing End Function 

我可以使用键盘快捷方式的任何地方,并保存没有问题。 我可以在API调用单个单元格上使用它,然后按ctrl + s ,它可以很好地保存。 但是,如果我select多个,然后按ctrl + alt + c然后保存与ctrl + s它破坏保存和恢复到以前保存不让我打开或查看任何与损坏的版本的问题。