VBA webservcie调用需要时间,而excel则不响应

时间:2022-10-19 21:31:32

I have this web-service call in excel through VBA.

我通过VBA在excel中进行了这个Web服务调用。

Req.Open "POST", MyURL, False
Req.setRequestHeader "Content-Type", "text/xml"

Req.send (sReq)

In this Req.send (sReq) takes time to respond when sReq length is too much. During this time excel goes not responding and then comes back to live and proceed to next line in the code.

在这个Req.send(sReq)需要时间来响应sReq长度太多。在此期间,excel没有响应,然后返回实时并进入代码中的下一行。

Can you suggest how can I stop my excel going to Not responding on this step ?

你能建议我怎样才能阻止我的excel在这一步没有响应?

1 个解决方案

#1


0  

Unfortunately this is not possible with the out of the box Excel/VBA.

不幸的是,开箱即用的Excel / VBA无法实现这一点。

To keep excel responsive during the web request you would need it to execute asynchronously (on a separate thread) but since VBA runs on a single thread this is not possible.

为了在Web请求期间保持excel响应,您需要它以异步方式执行(在单独的线程上),但由于VBA在单个线程上运行,因此无法实现。

You could however write a VSTO (Visual Studio Tools for Office) add in for excel using VB.NET or C#.NET, this could add custom ribbon tab where you can put a button to initiate your web request asynchronously.

但是,您可以使用VB.NET或C#.NET为excel编写VSTO(Visual Studio Tools for Office),这可以添加自定义功能区选项卡,您可以在其中放置按钮以异步方式启动Web请求。

#1


0  

Unfortunately this is not possible with the out of the box Excel/VBA.

不幸的是,开箱即用的Excel / VBA无法实现这一点。

To keep excel responsive during the web request you would need it to execute asynchronously (on a separate thread) but since VBA runs on a single thread this is not possible.

为了在Web请求期间保持excel响应,您需要它以异步方式执行(在单独的线程上),但由于VBA在单个线程上运行,因此无法实现。

You could however write a VSTO (Visual Studio Tools for Office) add in for excel using VB.NET or C#.NET, this could add custom ribbon tab where you can put a button to initiate your web request asynchronously.

但是,您可以使用VB.NET或C#.NET为excel编写VSTO(Visual Studio Tools for Office),这可以添加自定义功能区选项卡,您可以在其中放置按钮以异步方式启动Web请求。