Macro won't run in my latest system(capturing data) - excel

I have 2 macro version code that runs in old version of PCOMM System(capturing data). However After the update of latest PCOMM System(Capturing data). My macro will run as "Macro run complete" but the data didn't reflect in excel.
Here's my Version 1 My code can't capture data in my new latest PCOMM system(capturing data site) However macro says "Macro Run Complete!" to get the data. Show images and sample code below
Public Function Extra_Init() As Boolean On Error
GoTo ExitExtraInit
Extra_Init = False
Set goExtraSys = CreateObject("PCOMM.autECLConnList")
goExtraSys.Refresh
Set goSessions = CreateObject("PCOMM.autECLOIA")
goSessions.SetConnectionByHandle (goExtraSys(1).Handle)
giSessionCount = goExtraSys.Count
If giSessionCount = 1 Then
Set goSession = CreateObject("PCOMM.autECLPS")
goSession.SetConnectionByHandle (goExtraSys(1).Handle)
If goSession.CommStarted Then
Extra_Init = True
Else
Extra_Init = False
End If
End If
Exit Function
Here's my Version 2 My Microsoft Visual Basic when being run, an error prompts showing "class not registered"
Sample images below.
Error appears in this part of code.
Set Exl = GetObject(, "Excel.Application")
Set Extra = CreateObject("PCOMM.autECLConnList")
Extra.Refresh
Thank you in advance!
Get the data in my latest version of PCOMM System

Related

Is there a resolution in VBA for the error Run-time error '429' when trying to connect to a website?

I am trying to create a VBA to download a google sheet into excel so I can compile stock market data daily. I would simply use power query for this but I am doing this on my personal laptop which is a mac and does not support power query. I am relatively new to coding so have been leaning on following online instructions. The instruction includes this:
Set objWebCon = CreateObject("MSXML2.XMLHTTP.3.0")
This line when ran creates an error message saying:
"
Run-time error '429':
ActiveX component can't create object
"
I think the issue lies within the fact that the instruction is based on a windows operating system. Any solution I've searched for is specific to windows operating systems.
Does anybody here know if I can change the "MSXML2.XMLHTTP.3.0" part of my code to fit it better to mac? Not sure if this is what needs to be done but any guidance would be super appreciated.
I attached my full code below but feel free to ignore it if not relavent. Thank you!!
Sub DownloadGoogleSheets()
Dim ShtUrl As String, Location As String, FileName As String
Dim objWebCon, objWrit As Object
'Sheet Url
ShtUrl = "https://docs.google.com/spreadsheets/d/1wpA_epxtlz96sxETqKttJwsy9Aubb15H8xslcSQ20T0/export?format=csv&id=1wpA_epxtlz96sxETqKttJwsy9Aubb15H8xslcSQ20T0" & gid = 1319327791
'Location
Location = ThisWorkbook.Path & "\" '/Users/[myName]/Desktop/Stock Analysis/n"
'FileName
FileName = "GoogleSheet.csv"
'Connection to Website
Set objWebCon = CreateObject("MSXML2.XMLHTTP.3.0")
'Writer
Set objWrit = CreateObject("ADODB.Stream")
'Connecting to the Website
objWebCon.Open "Get", ShtUrl, False
objWebCon.Send (ShtUrl)
'Once page is fully loaded
If objWebCon.Status = 200 Then
'Write the text of the sheet
objWrit.Open
objWrit.Type = 1
objWrit.Write objWebCon.ResponseBody
objWrit.Position = 0
objWrit.SaveToFile Location & FileName
objWrit.Close
End If
Set objWebCon = Nothing
Set objWrit = Nothing
End Sub

silent logon to sap bw server via excel vba script and bexanalyzer

we are running SAP BW with BExAnalyzer 7.5. I've been trying for days to establish a connection to the SAP - Server, but unfortunately I am not even receiving an error message. So it seems the logon has succeeded, but no data from BW is fetched, so I am assuming there is a problem in the logon. Please help!
Function LogonToServer() As Boolean
LogonToServer = False
Dim myConnection As Object
Set myConnection = Run("'C:\Program Files (x86)\Common Files\SAP Shared\BW\BExAnalyzer.xla'!SAPBEXgetConnection")
With myConnection
.client = "xxx"
.user = "xxx"
.Password = "xxxx"
.Language = "DE"
.systemnumber = "xxx"
.system = "xxx"
.ApplicationServer = "xxx"
.SAProuter = ""
.Logon 0, True
End With
If myConnection.IsConnected <> 1 Then
'launch the Logon Dialog for manual connection
myConnection.Logon 0, False
If myConnection.IsConnected <> 1 Then
MsgBox "something went wrong ..."
Exit Function
End If
End If
If myConnection.IsConnected = 1 Then
LogonToServer = True
End If
Run "BExAnalyzer.xla!SAPBEXinitConnection"
End Function
SAP Note 2541995 says that the cause is that the Password property is not available in 7.5. It suggests that you can reconnect if you are using Single Sign On (SSO). It also points to note 2635165 that is a front end patch that may fix the issue with the password property. The code you attached does work with version 7.4 and I experienced similar issues with 7.5 but do not have access to download the patch. I'll try and get the front end patch and test again and update my answer with the results.

How to access SAP using Excel VBA?

I am trying to log on to SAP. The Excel VBA code gives me a popup window confirming my information however when I submit the form it does not take me to a new SAP window.
Additionally is there a way to automate all the popup boxes asking for confirmation on my information? I want this code eventually to run at certain times of the day, and I might not be available to input any data.
Sub login1()
Dim sap As Object
Dim conn As Object
Set sap = CreateObject("SAP.Functions")
Set conn = sap.Connection
conn.System = "System Test Environment"
conn.client = "100"
conn.user = "user"
conn.Password = "password"
conn.Language = "EN"
If conn.logon(0, False) <> True Then
MsgBox "Logon to the SAP system is not possible", vbOKOnly, "Comment"
Else
End If
End Sub
This Macro will never open a SAP Window - it will create an SAP-Object within VBA where you can work with SAP-RFC-Functions. (Reading Data from SAP, Writing Data into SAP)
In your version the SAP connection will be unaccessible after "End Sub". You have to declair the Object outside the sub.
This works silent (without dialog) for me:
Dim sap As Object
Public Function login1() As Boolean
Set sap = CreateObject("SAP.Functions")
sap.Connection.System = "System Test Environment"
sap.Connection.client = "100"
sap.Connection.user = "user"
sap.Connection.Password = "password"
sap.Connection.Language = "EN"
If sap.Connection.logon(0, False) <> True Then
sap.RemoveAll
MsgBox "Logon to the SAP system is not possible", vbOKOnly, "Comment"
Else
login1 = true
End If
End Function
Public Function SAPLogoff()
On Error Resume Next
sap.RemoveAll
sap.Connection.logoff
LoggedOn = False
Set sap = Nothing
'Set conn = Nothing
End Function
Since you want to "open a new SAP Window" you have to make a different approach!
At First try to open the new instance of SAP from the DOS Commandline with "sapshcut":
C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut.exe -system="System Test Environment" -client="100" -user="user" -password="password" -language="EN"
If your SystemName has no Spaces (and I belive so!) then you can write it also like:
C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut.exe -system=SystemTestEnvironment -client=100 -user=user -password=password -language=EN
When this call works with your credentials, then you can transfer it to Excel like this:
Sub login1()
Call Shell("C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapshcut.exe -system=SystemTestEnvironment -client=100 -user=user -password=password -language=EN",vbNormalFocus)
End Sub
You could also add a transaction by adding "-command=your_tcode" to the String.
If your have spaces in the parameters and you could only start it with -system="System Test Environment" from the Commanline, you will have to escape this in Excel with -system="""System Test Environment""" (!)

New Defect from Excecution Grid when Status is changed to failed

I want to open the Defect Window from the TestSet's Execution Grid when the "TC_STATUS" is "failed"
The following code seems only to work when I perform a "full" run
Actions.Action("Defects.NewDefect").Execute
or
Actions.Action("StepsView.NewDefect").Execute
I already tried:
Actions.Action("TestSetView.NewDefect").Execute
but this does nothing
You can post a new defect automatically each time test instance status is changed and link this new defect to currently selected test instance.
In Test Lab module script workflow put this code:
Sub TestSetTests_FieldChange(FieldName)
On Error Resume Next
If FieldName = "TC_STATUS" and TestSetTest_Fields.Field("TC_STATUS").Value = "Failed" Then
Set BugFact = TDConnection.BugFactory
Set NewBug = BugFact.AddItem(null)
'Fill new defect fields
NewBug.Summary = "New Defect"
NewBug.Field("BG_SEVERITY") = "3-High"
NewBug.Field("BG_STATUS") = "New"
NewBug.Field("BG_DETECTION_DATE") = "2016-01-01"
'...
NewBug.Post()
TestInstanceId = TestSetTest_Fields.Field("TC_TESTCYCL_ID").Value
Set TestInstanceFact = TDConnection.TSTestFactory
Set TestInstance = TestInstanceFact.Item(TestInstanceId)
Set NewBugLinkFact = TestInstance.BugLinkFactory
Set NewBugLink = NewBugLinkFact.AddItem(null)
NewBugLink.TargetEntity = NewBug
NewBugLink.Post
End If
On Error GoTo 0
End Sub
Or if you are working with ALM 12.53, you can try executing masthead "New Defect" action available from all modules.
Actions.Action("HeaderActions.HeaderNewDefect").Execute

Check if an Add-in is installed and running VBA

I am trying to check if an add-in is installed and running. I am using this piece of code:
On Error Resume Next:
Set SolverNome1 = AddIns("Solver Add-In") 'Solver may have two different names
Set SolverNome2 = AddIns("Solver")
MsgBox IsEmpty(SolverNome1)
MsgBox IsEmpty(SolverNome2)
If IsEmpty(SolverNome1) And IsEmpty(SolverNome2) Then
MsgBox "Install Solver add-in before trying to install this add-in.", vbExclamation
Application.myAddInName.Installed = False 'uninstall my add-in
End If
The problem is that even with the Solver Uninstalled I still get IsEmpty(SolverNome1) = false so my condition clause doesn't work as desired. I guess there I am misunderstanding the concept of installed or not. What piece of code should I be using to check if solver is running?
Answering my on question:
It is necessary to access the .installed property like this:
myBoolean1 = SolverNome1.Installed 'will return false because the add-in is set and not installed
myBoolean2 = SolverNome1.Installed 'won't return because add-in is not set

Resources