Basic script error in PCDMIS 2019

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic script error in PCDMIS 2019

    Hello all, I've been looking thru the forum for relevant topics but could not find exactly the same issue so i'm hoping some new eyes will see this and maybe have an answer. We are updating from 2010 to 2019 because our IT department is mandating that everyone be at Windows 10 operating system. We have a script that was written 15 years ago that works great for what we need but it will not work on the new platforms. We get a "class not registered" error when trying to execute for the line : Set oExcelBroker = CreateObject("PCDMISUTILS.cExcelBroker")


    Here is the code in it's entirety:

    Attribute VB_Name = "ExcelScript"
    Sub Main()
    Dim oxl As Object
    Dim lsSheetName As String
    Dim lbReopenBetweenRuns As Boolean
    Dim oExcelBroker As Object
    Set oExcelBroker = CreateObject("PCDMISUTILS.cExcelBroker")
    Set oxl = oExcelBroker.GetExcel()
    Set oExcelBroker = Nothing
    On Error Resume Next
    lsSheetName = ""
    lsSheetName = oxl.Workbooks("GHSP_Blank.xlsm").Name
    If lbReopenBetweenRuns Then
    If lsSheetName <> "" Then
    oxl.Workbooks("GHSP_Blank.xlsm").Close False
    End If
    oxl.Workbooks.Open "C:\JDS\GHSP_Blank.xlsm", 3, False
    Else
    If lsSheetName <> "" Then
    oxl.Workbooks("GHSP_Blank.XLSM").Activate
    Else
    On Error GoTo 0
    ' oxl.Workbooks.Open "C:\JDS\GHSP_Blank.xlsm", 3, False
    End If
    End If
    lsSheetName = oxl.ActiveWorkbook.Name
    oxl.Run lsSheetName & "!Sheet1.main"
    oxl.ActiveWorkbook.Save
    oxl.Visible = True
    Set oxl = Nothing
    End Sub




    I believe it has something to do with the 32 vs 64 bit setup. Any help would be greatly appreciated!

    Josh



  • #2
    I don't have PC-DMISUTILS, maybe you can send me yours. I did compile the script in the VBScript editor, without issues. I am using Windows 10 X64 and running as administrator, at least for this test. Did you try As Administrator?

    Comment


    • #3
      I believe PCDMISUTILS.dll is an old "helperfile". According to the error message, this file is no longer installed or registered on the computer running the script. You could try copying it/installing/registering that file to the computer again (from the old PC-DMIS installation) to get the script running again.

      Best would be to edit the script to not depend on PCDMISUTILS.dll at all, since that file no longer installs with PC-DMIS. There is another file called PCDUTILITIES.dll but it doesn't seem to have the cExcelBroker function (since the script can't find it).
      PC-DMIS CAD++ 2o19 R1 SP10

      Comment


      • #4
        I've come across this before but a long time ago. Here's what I remember (it's pretty vague but should point you in the right direction.)

        PCDmisutile Excelbroker was a tool for managing excel from pc-dmis (or something) - I think it was primarily for managing workbooks (i.e. opening a workbook, closing a workbook) BUT how this is managed depends on whether excel was already open and if other books were already open etc.

        The point is it no longer exists / gets registered / works on later versions. The solution I implemented was to basically recode what the excelbroker was doing by other methods. It was quite easy once I figured out what the **** the broker was actually doing.


        I'm a little confused however as I'm not sure what your script is meant to do exactly - what does it accomplish?
        Automettech - Automated Metrology Technology

        Comment


        • #5
          Attribute VB_Name = "ExcelScript"
          Sub Main()
          Dim oxl As Object
          Dim lsSheetName As String
          Dim lbReopenBetweenRuns As Boolean

          Set oxl = CreateObject("Excel.Application")

          On Error Resume Next
          lsSheetName = ""
          lsSheetName = oxl.Workbooks("GHSP_Blank.xlsm").Name
          If lbReopenBetweenRuns Then
          If lsSheetName <> "" Then
          oxl.Workbooks("GHSP_Blank.xlsm").Close False
          End If
          oxl.Workbooks.Open "C:\JDS\GHSP_Blank.xlsm", 3, False
          Else
          If lsSheetName <> "" Then
          oxl.Workbooks("GHSP_Blank.XLSM").Activate
          Else
          On Error GoTo 0
          ' oxl.Workbooks.Open "C:\JDS\GHSP_Blank.xlsm", 3, False
          End If
          End If
          lsSheetName = oxl.ActiveWorkbook.Name
          oxl.Run lsSheetName & "!Sheet1.main"
          oxl.ActiveWorkbook.Save
          oxl.Visible = True
          Set oxl = Nothing
          End Sub

          Changing it to above should work - BUT it might depend on if Excel is already open as to how it behaves with any other already open workbooks etc.

          Automettech - Automated Metrology Technology

          Comment


          • #6
            Thanks everyone for the responses. What this does for us is collects the data after we run a part and adds to the excel file to accumulate the data as we run. i've been able to get it to work but i'm running in to the problem of it opening multiple instances if one is already open which creates problems obviously. I'm about to try what NinjaBadger posted and see if it works.

            thanks!

            Comment


            • #7
              Badger you were right on. It now works but does not like it if the file is already open. Somehow it used to be able to tell if it was open and amend the open file rather than reopen it and cause confusion. For now though, as long as it is closed it works. if i can figure out how to get it to "look" for the file being open i'll post an update.

              Do you have any sites or books you recommend for understanding this code? I've been able to do most of the editing of this by trial and error / internet searches but it would be nice to actually understand the code.

              thanks again!!

              Comment


              • NinjaBadger
                NinjaBadger commented
                Editing a comment
                If I remember for excel you can use GetObject (with error trapping) to check if Excel is already open and if so get that instance of excel to use. If GetObject fails then you use CreateObject to get hold of Excel.

            • #8
              help menu kind of helps... best place to start for me is to find a problem first, that narrows the mounts of information you'd have to dig up.
              PcDmis 2015.1 SP10 CAD++
              Global 7-10-7 DC800S

              Comment

              Related Topics

              Collapse

              Working...
              X