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

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.

Related

Excel365 VBA Compile Error on Mac for Generating Outlook Events - 'A Project or Library Cannot be Found'

I'm trying to automatically generate outlook events using Excel VBA (on Excel v16.68 or VBA 7.1). The same code works perfectly on Windows OS but encountering 'A Project or Library Cannot be Found' error on 'OutApp As Outlook.Application' when tried on Mac OS for following line:
Dim OutApp As Outlook.Application, OutEvent As Outlook.AppointmentItem
Any suggestions on resolving the error or an alternative?
Thanks!
Any suggestions on resolving the error or an alternative?
Thanks!
VBA is only supported for Excel, Power Point, and Word under Office for Mac. Outlook is not exposed.

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.

VBA Run Time Error -2147221164(80040154) Class Not Registered

Good morning, afternoon, evening or whenever you are reading this.
That's the problem, I have a macro and two PC's
PC One (1): Which Run the macro perfectly.
PC Two (2) Which drops the error in the title.
The macro Connects SAPLogon, and PC Two breaks in this line:
Set Locx = CreateObject("SAP.LogonControl.1")
And here is the function:
Function SAPLogon() As Boolean
Set Lockx = CreateObject("SAP.LogonControl.1")
Set Conn = Lockx.NewConnection
Conn.Language = "S"
SAPLogon = Conn.logon(0, False)
Boths PC have the next exact vba references:
Visual Basic For Applications
Microsoft Excel 16.0 Object Library
OLE Automation
Microsoft Office 16.0 Object Library
Microsoft Forms 2.0 Object Library
SAP GUI Scripting API
But here is my big suspicion about why the macro doesn't run on PC Two:
PC One (1) Has Microsoft Office Personal Plus 2016 32-bit and PC Two Has Microsoft Office Personal Plus 2016 64-bit
The macro has been coded by another employee in 2002 (So I Think it's a 32-bit macro)
The question is:
Can 64 Bit Excel run 32 Bits Macros? How?
Thanks and Cheers
The issue here is that the SAP GUI is a 32bit application, and provides 32bit ActiveX controls for scripting in VBA. These will not work from 64bit Excel, however there is a solution. The comment above refers to another answer that explains more, but there are two solutions I'll summarise:
If you are able to install a new GUI then the latest version, 770 released February 2021 includes an optional install of 64bit NWRFC. This will install additional 64bit OCX controls that will work from 64bit Excel and VBA. (see https://stackoverflow.com/a/68906306/5087459).
If you need to use an older GUI then you will need to make a registry change using a surrogate as described in https://stackoverflow.com/a/65017544/5087459.

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!

Performance issue with a new Visio instance

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

Resources