+ Reply to Thread
Results 1 to 2 of 2

Unable to set the text property of the characters class

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2017
    Location
    SC
    MS-Off Ver
    2016
    Posts
    27

    Unable to set the text property of the characters class

    I have an excel program that allows users to add a row or delete a row in excel, then the following code to add text to the shape on the page, which corresponds to the numbers input into the rows:

    Function AddTextToShape(shp As Shape, _
                            sText As String, _
                            Optional bAppend As Boolean = False) As Boolean
      ' Adds or appends text to a shape
      Dim i             As Long
      Dim iBeg          As Long
    TextBox1.MultiLine = True
      On Error GoTo Oops
      With shp.TextFrame
        If bAppend Then
          iBeg = .Characters.Count
        Else
          .Characters.Text = vbNullString
        End If
    
        For i = 1 To Len(sText) Step 255
          .Characters(iBeg + i).Text = Mid(sText, i, 255)
        Next i
      End With
      AddTextToShape = True
    End Function
    
    Sub GenerateReport_Click()
    
    a = "Cognitive Processing Ability:   Cognitive, or mental, processes " + vbNewLine + vbNewLine
    
    b = "Crystallized Intelligence (Gc):   Crystallized Intelligence "
    c = Range("STUDENTNAME") + "'s performance on the measures of Crystallized Intelligence fell within the " + Range("GCD") + " range (SS= "
    d = Range("GCSS")
    e = "; PR= "
    f = Range("GCPR")
    g = "), which suggests that these skills " + Range("GCF") + " " + Range("SMALLHIM") + " learning and performance. "
    If Range("GCF") = "inhibit" Then
    Ga = Range("STUDENTNAME") + " may benefit from increased exposure to environments rich in language that would provide new and varying experiences."
    End If
    
    
    ActiveSheet.Shapes("Report").TextFrame.Characters.Text = a & b & c & d & e & f & g & Ga
    When I don't add or delete rows this code works, however, when a row is added or deleted I get the 1004 error: unable to set the text property of the characters class.

    What am I missing? This is driving me crazy!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Unable to set the text property of the characters class

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.

    To add a file to a post

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Unable to get SUM property of the worksheetfunction class
    By cmbh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-15-2016, 11:08 PM
  2. Unable to get the Vlookup Property of the WorkSheetFunction Class
    By jayeshsondhi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2015, 03:57 AM
  3. [SOLVED] error 1004 unable to get caption property of the characters class
    By WillemB in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-19-2014, 06:45 AM
  4. Unable to set name property of Font Class
    By booo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2011, 05:46 PM
  5. [SOLVED] Unable to get Match property of the WorksheetFunction class
    By C++User in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-03-2006, 09:55 AM
  6. unable to get the Interior property of the range class
    By joe in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-30-2005, 08:20 PM
  7. Unable to Set XValues property of the Series class
    By PGalla06 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-30-2005, 11:16 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1