Performance issue with a new Visio instance - excel

i would like to start a new Visio instance out of excel and execute some code.
This works well, but it takes about 100x times longer to execute the code than executing the code directly in a visio macro.
Visio 2003
Dim visio_app As New Visio.Application
Dim doc As Visio.Document, pg As Visio.page
Set doc = visio_app.Documents.Open(.......)
Set pg = visio_app.ActivePage
'Performance problem runing this methode
delete.doDeleteDeleted visio_app, pg
......
No Performance issue when i start the code directly in visio
delete.doDeleteDeleted Application, Application.ActivePage
does anybody knows how to fix it?
Thank you for your help!

I already found a workaround. I created a visio file which includes the doDeleteDeleted methode and a run sub which executes doDeleteDeleted. Then I use visio_app.ExecuteLine(....) to execute the code in the Visio file. This works, but its unattractive

Related

Message filter indicated that the application is busy

I've looked through a lot of the other threads on this but none of those solutions has helped me. I'm trying to open Excel via Microsoft.Office.Interop.Excel to load data into a worksheet. I have tried this solution but that did not solve my issue. I have also seen others say that settings DispayAlerts to False helped them, however that did not resolve my issue. I even tried adding in a 5 second wait to give Excel time to fully open but still no luck. A small sample of my code that I'm using to open Excel is below. This is working without issues on two machines that I've installed my application on, but the third on (2012 R2 64-bit server running Excel 2010 32-bit) is causing me all kinds of headaches. Unfortunately, because I can't replicate this on my testing machine with Visual Studio installed, I can't debug the error. Any help would be greatly appreciated.
Dim _excel As New Excel.Application
Dim WBook As Excel.Workbook = Nothing
_excel.DisplayAlerts = False
WBook = _excel.Workbooks.Open(Path.Combine(FolderPath, FileName))
I was able to get this resolved. Creating an OleMessageFilter with this link and converting my BackgroundWorker to an STA Thread with help from this link seemed to do the trick. Had to pretty much rewrite my entire background process but at least it's working. Thanks for all the help!

Code runs fine in .vbs file but not in a UFT script - Error 429

I have a line of code:
Dim objExcel
Set objExcel = CreateObject("Excel.Application")
Msgbox Err.number
When I run this code in a .vbs file, It gets executed successfully without throwing any error(Err.number=0).(I just created a text file on desktop, changed its extension from txt to vbs, inserted this code, saved and double-clicked the vbs file -It ran correctly without errors - Not sure if this approach uses 32 bit or 64 bit wscript.exe by default. I need to understand this. Could someone please explain this also apart from the main issue below?)
Issue:
When I place this code in a UFT script, It is throwing the error 429 - ActiveX component can't create Object. It remains stuck on the line Set objExcel = CreateObject("Excel.Application") for some time and finally throws the error 429.
Additional Info:
Windows 7(64 Bit)
UFT - 32 Bit - Version: 12.02
Excel - 32 Bit(version - 14.0.7181.5000)
I have looked at a lot of places for this issue and I think It has something to do with some architecture mismatch as mentioned in a few answers here(Not sure If I am pointing you guys to the correct place).
I would really appreciate If someone explains why the code runs fine in vbs but not in UFT script? I really need to make it work in UFT scripts.
Thanks for helping.
CreateObject("Excel.Application") throws replay error when ActiveX is not selected.
Make sure that the ActiveX add-in is selected, in the UFT add-in manager.

Excel VBA with SAP GUI 7.40 - SAP.Functions not working

I have a Excel VBA which connects to SAP, pulls some data and does some processing on it. It was working fine with SAP GUI 7.20 But it stopped working when I installed SAP GUI 7.40.
My code is as below :
Dim obBAPICall As Object
' * Create object
Set obBAPICall = CreateObject("SAP.Functions")
.
.
I get following error :
I've already gone through some weblinks and I believe I've all the required references. (In fact, I've added many more in order to troubleshoot the problem).
My SAP GUI version is :
Any help is highly appreciated.
Thank you.
Edit : Following code does not have any problem :
Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
Got it ! The problem was with the latest MS office product (and not with SAP GUI 7.40). The IT guys had rolled out some updates in MS Office and it was creating a problem. I restored MS Office and it is working fine now.

How to force Excel VBA to use updated COM server

I'm developing a COM server to be used from Excel VBA. When I update the server (edit code, unregister, re-register) Excel seems to carry on using the original version of the COM server, not the updated version. The only way I have found to get it to use the updated version is to close and re-open Excel, which gets a bit irritating. Is there a way to force Excel to use the newly registered version (maybe some kind of "clear cache" option)?
More details:
The server is being developed in Python using win32com.
In VBA I'm doing something like:
set obj=CreateObject("Foo.Bar")
obj.baz()
Where Foo.Bar is the COM server I have registered in the registry.
If I unregister the server then run the VBA code, I get a "can't create object" error from VBA, so it must realise that something is going on. But once I reregister it picks up the old version.
Any hints appreciated!
Thanks,
Andy
I've found a solution to my problem - the general idea is to set things up so that the main COM server class dynamically loads the rest of the COM server code when it is called. So in Python I've created a COM server class that looks something like:
import main_code
class COMInterface:
_public_methods_ = [ 'method1' ]
_reg_progid_ = "My.Test"
_reg_clsid_ = "{D6AA2A12-A5CE-4B6C-8603-7952B711728B}"
def methods(self, input1,input2,input3):
# force python to reload the code that does the actual work
reload(main_code)
return main_code.Runner().go(input1,input2,input3)
The main_code module contains the code that does the actual work and is reloaded each time the COM method is called. This works as long as the inputs don't change. There will presumably be a runtime penalty for this, so might want to remove the reload for the final version, but it works for development purposes.
Just a suggestion, have you tried to Unload the object? Maybe create a button in your excel spredsheat that force to unload the object.
I hope it helps

Scriptom (groovy) leaves Excel process running - am I doing something wrong?

I am using the Scriptom extension to Groovy 1.7.0 to automate some processing using Excel 2007 under Windows XP.
This always seems to leave an Excel process running despite my calling quit on the excel activeX object. (There is a passing reference to this phenomenon in the Scriptom example documentation too.)
Code looks like:
import org.codehaus.groovy.scriptom.ActiveXObject;
def xls = new ActiveXObject("Excel.Application")
xls.Visible = true
// do xls stuff
xls.Quit()
The visible excel window does disappear but an EXCEL process is left in the task manager (and more processes pile up with each run of the script).
There are no error message or exceptions.
Can anyone explain why the Excel process is left behind and is there any way to prevent it from happening?
This works:
xls.Quit()
Scriptom.releaseApartment()
The javadocs state:
In some cases, the JVM can close
before everything is cleaned up, which
can leave automation servers
(especially Excel) hanging. Call this
before your script exits to get
correct behavior from automation
servers.
Looks like you are missing
xls.release();
like it is done here.

Resources