I have created a script which allows me to import from one of my programs and place the information in designated cells in Excel. The problem is, I have rounded everything down to two possible scenarios. What I have seen is that with my original script, the first .cmd runs throughout the worksheet, if I place an ElseIf on the second variable, both .cmd lines run together. I don't want this either, what I would like to see happen is that if when the script finds the next string, if it is true of variable two, I do not want anything imported fitting the first variable. Is there a way to toggle between these variables? I have pasted my code here, any help would be awesome.
Option Explicit
Sub main()
Dim app As Object, cmds As Object, cmd As Object, part As Object
Set app = CreateObject("PCDLRN.Application")
Set part = app.ActivePartProgram
Set cmds = part.Commands
Dim LookForChar
LookForChar = "."
Dim Pos, s As String, i As Integer
Dim Run As Integer, Offset As Integer
s = ""
Run = ActiveSheet.Cells(1, 9)
Offset = ActiveSheet.Cells(2, 9)
Run = Run + 1
ActiveSheet.Cells(1, 9) = Run
i = 10
For Each cmd In cmds
If cmd.IsDimension Then
If cmd.Type = (DIMENSION_TRUE_START_POSITION Or _
DIMENSION_START_LOCATION) Or s <> cmd.ID Then
If cmd.ID <> "" Then s = cmd.ID
If cmd.Type <> DIMENSION_TRUE_START_POSITION And _
cmd.Type <> DIMENSION_START_LOCATION Then
If Run < 49 Then
ActiveSheet.Cells(i, 3) = cmd.DimensionCommand.NOMINAL
ActiveSheet.Cells(i, 10) = cmd.DimensionCommand.Plus
ActiveSheet.Cells(i, 12) = cmd.DimensionCommand.Minus
End If
ActiveSheet.Cells(i, (Offset + 15)) = cmd.DimensionCommand.Measured
End If
ElseIf cmd.Type <> DIMENSION_TRUE_END_POSITION Or DIMENSION_END_LOCATION Then
If Run < 49 Then
ActiveSheet.Cells(i, 1) = s
ActiveSheet.Cells(i, 2).Font.Bold = True
End If
If Run < 49 Then
ActiveSheet.Cells(i, 4) = cmd.DimensionCommand.NOMINAL
ActiveSheet.Cells(i, 5) = cmd.DimensionCommand.Plus
'ActiveSheet.Cells(i, 6) = cmd.DimensionCommand.Minus
End If
ActiveSheet.Cells(i, (Offset + 3)) = cmd.DimensionCommand.Measured ' + 6
'ActiveSheet.Cells(i, (Offset + 7)) = cmd.DimensionCommand.Deviation
'ActiveSheet.Cells(i, (Offset + 8)) = cmd.DimensionCommand.OutTol
End If
If Trim(ActiveSheet.Cells(i, (Offset + 3))) <> "" Then
i = i + 1
End If
End If
Next cmd
Offset = Offset + 5
ActiveSheet.Cells(2, 9) = Offset
End Sub
Bookmarks