Your Products have been synced, click here to refresh
Is Cmds Dim'd as Cmds As PCDLRN.Commands or something else? If that is correct Im getting an "Expression is of type 'PCDLRN.Commands', which is not a collection type" error.
Here is the whole program:
Imports PCDLRN Imports System Imports System.IO Imports System.Text Imports Microsoft.Office.Interop.Excel Imports System.Threading Public Class Form1 Dim PCDApp As PCDLRN.Application Dim pcdpartprograms As PCDLRN.PartPrograms Dim pcdActivePart As PCDLRN.PartProgram Dim WithEvents AppEvents As PCDLRN.ApplicationObjectEvents Dim Cmds As PCDLRN.Commands Dim Cmd As PCDLRN.Command 'Loads PC-DMIS and Opens the Part Program based on inputs Public Sub PCDLoad() Dim fname As String fname = "\\hemfile1\share\PartNumber\" & TextBox1.Text & "\Quality\CMM\Program Files\" & TextBox1.Text & " - " & TextBox2.Text & ".PRG" PCDApp = CreateObject("PCDLRN.Application") PCDApp.WaitUntilReady(60) Threading.Thread.Sleep(2000) pcdpartprograms = PCDApp.PartPrograms PCDApp.Visible = True PCDApp.SetActive() PCDApp.Maximize() pcdpartprograms.CloseAll() pcdpartprograms.Open(fname, "Machine1") VarSet() End Sub Public Sub VarSet() Dim PCDPart As Object pcdActivePart = PCDApp.ActivePartProgram Cmds = pcdActivePart.Commands For Each Cmd In [B][COLOR=#FF0000]Cmds [/COLOR][/B] [B][COLOR=#333333]Set Cmd = Cmds.Item(cnt)[/COLOR][/B] If [B]Cmd.Type[/B] = "Assignment" And Cmd.GetText(DEST_EXPR, 0) = "JOBNO" Then retval = Cmd.PutText("1234", SRC_EXPR, 0) End If Next Cmd endForm() End Sub 'Loads the Set-up Sheet if one is available, Then Loads PCDLoad Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim path As String = "\\hemfile1\share\PartNumber\" & TextBox1.Text & "\Quality\CMM\Program Files\" & TextBox1.Text & ".xlsx" If SetupSheet = True Then If System.IO.File.Exists(path) Then Process.Start("excel.exe", String.Format("/r {0}{1}{0}", """", path)) Else MessageBox.Show("No Set-Up Sheet Available") End If End If PCDLoad() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Me.Close() End Sub Private Sub endForm() Me.Close() End Sub 'Set-Up Sheet Code Private SetupSheet As Boolean Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = True Then SetupSheet = True Else SetupSheet = False End If End Sub End Class
The red bit is what is hanging things up.
Is Cmds Dim'd as Cmds As PCDLRN.Commands or something else? If that is correct Im getting an "Expression is of type 'PCDLRN.Commands', which is not a collection type" error.
Here is the whole program:
Imports PCDLRN Imports System Imports System.IO Imports System.Text Imports Microsoft.Office.Interop.Excel Imports System.Threading Public Class Form1 Dim PCDApp As PCDLRN.Application Dim pcdpartprograms As PCDLRN.PartPrograms Dim pcdActivePart As PCDLRN.PartProgram Dim WithEvents AppEvents As PCDLRN.ApplicationObjectEvents Dim Cmds As PCDLRN.Commands Dim Cmd As PCDLRN.Command 'Loads PC-DMIS and Opens the Part Program based on inputs Public Sub PCDLoad() Dim fname As String fname = "\\hemfile1\share\PartNumber\" & TextBox1.Text & "\Quality\CMM\Program Files\" & TextBox1.Text & " - " & TextBox2.Text & ".PRG" PCDApp = CreateObject("PCDLRN.Application") PCDApp.WaitUntilReady(60) Threading.Thread.Sleep(2000) pcdpartprograms = PCDApp.PartPrograms PCDApp.Visible = True PCDApp.SetActive() PCDApp.Maximize() pcdpartprograms.CloseAll() pcdpartprograms.Open(fname, "Machine1") VarSet() End Sub Public Sub VarSet() Dim PCDPart As Object pcdActivePart = PCDApp.ActivePartProgram Cmds = pcdActivePart.Commands For Each Cmd In [B][COLOR=#FF0000]Cmds [/COLOR][/B] [B][COLOR=#333333]Set Cmd = Cmds.Item(cnt)[/COLOR][/B] If [B]Cmd.Type[/B] = "Assignment" And Cmd.GetText(DEST_EXPR, 0) = "JOBNO" Then retval = Cmd.PutText("1234", SRC_EXPR, 0) End If Next Cmd endForm() End Sub 'Loads the Set-up Sheet if one is available, Then Loads PCDLoad Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim path As String = "\\hemfile1\share\PartNumber\" & TextBox1.Text & "\Quality\CMM\Program Files\" & TextBox1.Text & ".xlsx" If SetupSheet = True Then If System.IO.File.Exists(path) Then Process.Start("excel.exe", String.Format("/r {0}{1}{0}", """", path)) Else MessageBox.Show("No Set-Up Sheet Available") End If End If PCDLoad() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Me.Close() End Sub Private Sub endForm() Me.Close() End Sub 'Set-Up Sheet Code Private SetupSheet As Boolean Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = True Then SetupSheet = True Else SetupSheet = False End If End Sub End Class
The red bit is what is hanging things up.
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |