1

I have been given the task of converting the slower Macro Express Pro coding for IBM Personal Communications over to a VBScript/VBA version. The Macro Express Pro coding opens a predetermined profile from a specific location.

enter image description here

This process can take up to 30 seconds. VBScript does this in about a third of the time for a default profile (TN3270.WS). However, when we try opening the specific link highlighted in the UNET.txt file, we get this as an error:

Run-time error '440': Automation error

Here is the VBScript code we are trying to use:

Sub Main()
    Dim EName
    Dim autECLConnList, objConnMgr

    Set objConnMgr = CreateObject("Pcomm.autECLConnMgr")
    objConnMgr.autECLConnList.Refresh
    objConnMgr.StartConnection ("profile='C:\ProgramData\IBM\Personal Communications\UNET REWORK.ws' connname=a")
    Application.Wait (Now + TimeValue("00:00:12"))
    objConnMgr.autECLConnList.Refresh
    EName = objConnMgr.autECLConnList(1).Name
End Sub

The error occurs on the objConnMgr.StartConnection ("profile='C:\ProgramData\IBM\Personal Communications\UNET REWORK.ws' connname=a") line. We know we have the correct path to the profile because it's we found its location:

enter image description here

IBM says that if the profile name contains blanks, it "must to be surrounded by single quotes":

enter image description here

Can anyone provide some advice on what we're doing wrong or what we're missing?

Thanks.

Lou
  • 389
  • 3
  • 20
  • 38
  • VBScript or VBA which is it, the documentation shows VBA example and the error you are receiving comes from VBA, is the reference to VBScript a typo? – user692942 Feb 02 '18 at 19:19
  • No. You can type VBScript into any Microsoft Visual Basic editor and it will work. I do this all the time when I'm incorporating VBScript into Macro Express Pro macros to ensure the code works and shows me what errors are occurring that I'm not seeing in Macro Express. That's besides the point. The point is I'm able to start this connection: `objConnMgr.StartConnection ("profile=tn3270.ws connname=a")`, but not the one in my example. – Lou Feb 02 '18 at 19:24
  • Make sure that `C:\ProgramData` is not just link. Since the doc is asking for single quotes, use some `/` instead of backslash. you could also try a short path or an uri (`file://`) with the spaces encoded as `%20` or simply set the working directory before calling `CreateObject`. – Florent B. Feb 02 '18 at 20:03
  • @Lou amazing that [one reply](https://stackoverflow.com/questions/48589269/vbscript-starting-a-specific-profile-connection-in-ibm-personal-communications?noredirect=1#comment84176193_48589269) is actually more use in understanding the problem than your entire question. – user692942 Feb 02 '18 at 20:22
  • What about placing your `ws` file in the default location and trying, that will eliminate the path being the issue. – user692942 Feb 02 '18 at 20:25
  • @Lankymart I do apologize if my entire question is confusing. I'm the type of person who has to see all of an issue or I can't understand the concept, so when I post a question, I want everyone to see the same thing I'm seeing in an effort to "eliminate" confusion and not "create" it. The path for `UNET REWORK.ws` is the default location for IBM Personal Communications. This is where all the users will have the same profile stored. – Lou Feb 02 '18 at 20:44
  • @Lou so what happens when you try `objConnMgr.StartConnection ("profile='UNET REWORK.WS' connname=a")`? – user692942 Feb 02 '18 at 21:15
  • @FlorentB. I'm still getting the same error. – Lou Feb 06 '18 at 15:48
  • @Lankymart Still the same error. I tried that because the Usage Notes I added in my example say "The value may be either the profile name with no extension, the profile name with the .WS extension, or the fully qualified profile name path." – Lou Feb 06 '18 at 15:54
  • @Lou could it be you are using the wrong architecture environment *(32 bit vs 64 bit - have different COM registers)*? Problem for me is the explanation between what does work and what doesn't work is very vague and as a concequence the best you will get is educated guesses. – user692942 Feb 06 '18 at 20:00
  • @Lankymart I do apologize for being vague. I only get less than 600 characters to write, so I'm trying to be both concise and brief at the same time. My reply about the same error, `Run-time error '440': Automation error`, was in regards to your last post of what happens when I try `objConnMgr.StartConnection ("profile='UNET REWORK.WS' connname=a")`. I feel like I'm running out of options to try while not knowing the reason I'm getting the error. – Lou Feb 06 '18 at 21:15

1 Answers1

1

I found a way of doing what I need to do. I was looking too specific into starting a PCOMM session that I didn't even think of just running the .exe file and send it parameters. Here's how I did it:

Sub Main()
    Dim WShell

    Set WShell = CreateObject("WSCript.shell")

    WShell.Run """C:\Program Files (x86)\IBM\Personal Communications\pcsws.exe"" ""C:\ProgramData\IBM\Personal Communications\UNET REWORK.WS"""
End Sub

I'm sure this is a duplicate answer to another question out there, but most of the answers are more than a few years old and outdated. This solution is current and recently tested, so it is a more reliable source.

Lou
  • 389
  • 3
  • 20
  • 38