Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Hanging Indent
Sandra Truax 
         
3 years ago
I cannot figure this out, nor can ChatGPT.  I have a long text field formatted as Rich Text. What I'm trying to do is format it as hanging indent.  Following is the code from Chat GPT, but I get a Run-time error 424 on the "Set sel = Me.NoteText.SelText" code.

Private Sub SetHangingIndent()
    ' Set focus to the rich text field
    Me!NoteText.SetFocus
    
    ' Get the currently selected text in the rich text field
    Dim sel As Object
    Set sel = Screen.ActiveControl.SelText
    
    ' Check if any text is selected
    If Len(sel) = 0 Then
        MsgBox "Please select some text in the NoteText field.", vbInformation, "No Text Selected"
        Exit Sub
    End If
    
    ' Apply a hanging indent of 0.5 inches to the selected text
    sel.Paragraphs.Format.HangingIndent = True
    sel.Paragraphs.Format.FirstLineIndent = -0.5 * 1440  ' Convert 0.5 inches to twips (1 inch = 1440 twips)
End Sub

Kevin Yip  @Reply  
     
3 years ago
Hi Sandra, ChatGPT is erroneous is several places.  The "SelText" property is a string, not an object.  The code declares "sel" as an object, but then Len(sel) treats it as a string.  Finally, the "Paragraphs" object is available in Word VBA only.  

Your original goal is difficult to accomplish, since rich text in Access is a lot more limited in functionality than rich text in Word.  See picture below.  When you highlight text in Word, a lot more formatting options are available, including line and paragraph options (which include indentation).  When you highlight rich text in Access, only a few options appear.

To add indentation in Access rich text, you need to identity what a paragraph is in a rich text entry, and that is not a trivial task.
Kevin Yip  @Reply  
     
3 years ago

Richard Rost  @Reply  
          
3 years ago
I don't think it's possible to do a hanging indent in Microsoft Access rich text. And I'm finding the more that I work with GPT the more that it generates code with properties and methods that just don't simply exist in Access. I've seen it try to add JavaScript methods in VBA so just because it generated some code doesn't mean it's going to work.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/2/2026 8:29:22 AM. PLT: 2s