Message filter indicated that the application is busy - excel

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!

Related

Good VBA script fails to run on other computer

I have a very complex excel macro workbook. The VBA code seems to run pretty well on PC's at my location. As soon as I send it to a German colleague it fails to run in unexpected locations of the code.
The last problem I came across is a Runtime error 5 when the code try to modify the Caption of a UserForm (and some text boxes and cmd buttons as well).
Previously we faced with the same issue with SlicerCache(x).ClearManualFilter but somehow I healed itself...
My first thought was to break up the nest With and see which row causes the fail, but it's immediately the first row. I assume it'll do the same for all rows.
I have checked the windows and office settings:
I'm running Win10, English language settings and Hungarian formatting settings. -> Code running well.
My local colleagues run the same system with Hungarian language and formatting. -> Code running well.
The problematic colleague runs Win10 with German language and formatting settings. -> Code fails to run.
We both have the same Reference libraries in VBA editor, none missing. (I assume it's carried by the excel file itself.)
I have Microsoft 365 MSO (16.0.13801.21050) 32-bit, he running 16.013801.21004 32-bit. (I suppose the update scheduled by the IT department.) This portion of code months before my latest office update, so I don't think it's a cause.
The sub called by a CommandButton_Click event, and calls the user form zurueckExport. The form is deisgned so that can called for differnet purposes, so the captions have to be modified according to the needs.
I have ran out of ideas, don't see what and why cause it. Does anybody could give me some help to deal with this issue? I would be very glad.
Public Sub verExport()
With zurueckExport
.Caption = "Version Exportieren zum Creo"
.Label1.Caption = "Welche Version möchten Sie zum Creo exportieren?"
.CommandButtonExportieren.Visible = True
.CommandButtonZurueckladen.Visible = False
.CommandButtonKennlinie.Visible = False
.KennlinieFormat.Visible = False
.Show
End With
End Sub
The captions were too long, that generated the error message on the other computer.
Resolution:
I have added several different labels to the UserForm and modify their visibility instead of overwrite the caption.
Many thanks for #J0eBl4ck for the idea.

Constantly getting Err 1004 when trying to using Application.AddIns.Add

I'm trying to implement a bootstrap installer for my add-ins workbook, such that I can easily install the add-in for new users and send out updates. It works fine on my machine, but when having others test it, I get a runtime error when I try to call Set AI = Application.AddIns.Add(fileName:=fullPath, copyfile:=True). Specifically, the error is "1004: Unable to get the Add property of the AddIns class". I thought this was because the user needed to have "Trust access to the VBA project object model" enabled, but the error seems to occur even after they've toggled that box.
Other things I've checked:
The fullPath to the add-in is valid and the user can access the directory and the file
The user has the folder located at Application.UserLibraryPath
Any ideas?
Figured it out. It appears that the issue isn't one of permissions, but rather of whether a workbook is already open. Opening any workbook before running the Addins.Add prevented the error from occurring so I've simply added that into the program:
If Application.Workbooks.Count = 0 then Set wb = Application.Workbooks.Add()
Set AI = Application.AddIns.Add(fileName:=fullPath, copyfile:=True)
If not wb is nothing then wb.Close
Duke, perhaps it's the Trust Center settings on the recipients' machines. I have found this and may be helpful.
Best,
Danny
Check out VBA videos on ExcelVBADude on YouTube.

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.

Calling Excel from VFP9 on 64-bit machine

I have a VFP9 application which generates Excel files using Automation, starting with :
**oExcel = CREATEOBJECT(“Excel.Application”)
oWorkbook = oExcel.Workbooks.Add()**
. . .
Excel 2013 is being used. The sheet is then populated, formatted and saved . This works fine on a Windows 7 32-bit machine. However on a Windows 7 64-bit machine, some instructions fail. In particular :
**oworkbook.SaveAs(<NewFilename>)**
fails with the message “Unable to get the SaveAs property of the workbook class”
As a work-around, I have created before creating the Excel object, and then called :
**oworkbook.Save ()**
This works. Have other users experienced this; are there any other limitations on the use of Excel from VFP when running on a 64-bit machine.
Thanks
Neither oWorkbook.SaveAs() nor oWorkbook.Save() have any problems on a 64 bit machine (I assume you meant windows (7/8/10) 64). Your problem should be something else.
I've experienced the identical problem but the issue turned out to be that the user had a different version of Excel than I did. It wasn't the 64 bit vs the 32 bit. I solved it by defining:
#define xlNormal 39
That set the target version of the workbook. Here is a page about the enumeration: https://msdn.microsoft.com/en-us/library/office/ff198017.aspx
I have also found that, in applications where I am saving up to like 50, that I have to open, set the save flag, do my work then say SaveAs.
Good luck with this :) Please consider closing this question. I think you get like two points for that.

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.

Resources