Results 1 to 5 of 5

Thread: How to format inserted text?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    29

    How to format inserted text?

    Hi All

    I have a Word application that enables me to get data from a database and insert them into certain fields of the Word table. However the inserted text should be formatted as separate lines one line after the other, not
    continuously. Could anyone help me on this? Thanks in advance.

    Claire

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to format inserted text?

    Post your code, but the logic would be to use a vbNewline or vbCrLf (they are the same actually) to create a line break and
    position the next text on the next line.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    29

    Re: How to format inserted text?

    Hi Robdog888

    Here is my code:

    VB Code:
    1. sqlstring="Select Description from employee Where CompanyName= " & cname & ""
    2. Set rstEmp=dbs.OpenRecordset(sqlstring)
    3.  
    4. Do While Not rstEmp.EOF
    5.  
    6.   If IsNull(rstEmp.Fields("Description").Value=False then
    7.      Description=rstEmp.Fields("Description").Value
    8.   else
    9.     Description=""
    10.  end if
    11.  
    12.  for num=1 to maxnum
    13.  
    14. with myTable
    15.  
    16. .cell(num,1).Range.InsertAfter(Description)
    17.  
    18. End With
    19.  
    20.  
    21. Next num
    22.  
    23. rstEmp.MoveNext
    24. Loop

    I want to add code right after the line:

    VB Code:
    1. .cell(num,1).Range.InsertAfter(Description)

    that enable the next line not continuous, but start a new line.

    Thanks in advance

    Claire
    Last edited by clairexh; Jun 13th, 2005 at 07:55 AM.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2001
    Posts
    29

    Resolved [Resolved] Re: How to format inserted text?

    Hi robdog888

    After I posted my code, I tried add vbnewline into the line:

    VB Code:
    1. .cell(num,1).Range.InsertAfter(Description & vbnewline)

    it works perfectly, thanks a lot. I spent quite long hours to try to figure out.

    Cheers

    Claire
    Last edited by clairexh; Jun 10th, 2005 at 04:12 PM.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to format inserted text?

    Sorry for the delay in getting back to you.

    Good job and Thanks
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width