Copy Table Cell to Table Cell

Discussion in 'AutoCAD' started by Dan, Sep 13, 2004.

  1. Dan

    Dan Guest

    This is the code I am working with. I am trying to figure out how to select
    a cell that has an text string of "0", and copy it to an empty cell. So
    far, I can copy Cell-to-cell if both have strings, but not when one is
    empty.

    The code I have currently is:

    Public Sub CopyTableCell()

    Dim objTable As AcadTable
    Dim Pt As Variant
    Dim RI As Long
    Dim CI As Long
    Dim objTable2 As AcadTable
    Dim Pt2 As Variant
    Dim RI2 As Long
    Dim CI2 As Long

    On Error GoTo Err_Control
    Do
    GetEntityEx objTable, Pt, vbCrLf & "Select Cell to COPY: "
    objTable.Select Pt, Point3D(0, 0, 1), Point3D(0, 0, 1), 1, 1, False,
    resultRowIndex:=RI, resultColumnIndex:=CI
    GetEntityEx objTable2, Pt2, vbCrLf & "Cell Text: """ &
    objTable.GetText(RI, CI) & """" & vbCrLf & _
    "Select Cell to COPY to`: "
    objTable2.Select Pt2, Point3D(0, 0, 1), Point3D(0, 0, 1), 1, 1,
    False, resultRowIndex:=RI2, resultColumnIndex:=CI2
    objTable2.SetText RI2, CI2, objTable.GetText(RI, CI)
    Loop
    Exit_Here:
    Exit Sub
    Err_Control:
    Err.Clear
    Resume Exit_Here
    End Sub
    'Continually prompts for an object selection until an object is acquired or
    the operation is cancelled
    'Arguments: Identical to those required for GetEntity
    Public Sub GetEntityEx(ent As Object, pickedPoint, Optional Prompt)

    On Error Resume Next
    StartLoop:
    ActiveDocument.Utility.GetEntity ent, pickedPoint, Prompt
    If Err Then
    If ActiveDocument.GetVariable("errno") = 7 Then
    Err.Clear
    GoTo StartLoop
    Else
    Err.Raise vbObjectError + 5, , "User cancelled operation"
    End If
    End If

    End Sub

    'Converts the supplied doubles into a point
    'Arguments: An X, Y and optional Z value
    'Example: ThisDrawing.ModelSpace.AddCircle 0.25, Point3D(10, 10)
    Public Function Point3D(x As Double, y As Double, Optional z As Double = 0)
    As Variant

    Dim retVal(0 To 2) As Double

    retVal(0) = x: retVal(1) = y: retVal(2) = z

    Point3D = retVal

    End Function
     
    Dan, Sep 13, 2004
    #1
  2. Dan

    Dan Guest

    Figured it out.....If I select the top line of the cell, the value will
    copy...if this helps anyone else......Enjoy!
    Dan
     
    Dan, Sep 13, 2004
    #2
  3. Dan

    Dan Guest

    NP, Hope it helps.
    You may want to adjust the text formatting for your specific needs.

    Dan
     
    Dan, Nov 4, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.