Results 1 to 13 of 13

Thread: vb to word problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    vb to word problem

    Hii

    I have a program in vb in which there is a multiline textbox and the text in the text box are like after every line there is a blank line and then the other line of text and soo on.
    when i transfer the data from that text box into a word file i get small boxes before and after the line.
    how can i remove those small boxes..?

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: vb to word problem

    The small boxes represent carriage return and line feed characters (ASCII 13 and 10 respectively). Use Replace$() on the string to get rid of them.
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    Re: vb to word problem

    could you tell me where to use this Replace$() and on which string.
    is it while transfering the data from vb to word or where should i use it..?

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

    Re: vb to word problem

    Usse it in your code that transfers the data to Word. Post you code to see where to place it.
    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

  5. #5
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: vb to word problem

    post the code u are using to transfer....
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    Re: vb to word problem

    Hiii

    I have attached the files below.
    i am transfering the data from the text files into the word file and i have also attached the word file that i get after the data transfer from vb.
    and the multiline textbos is text1(7).
    Attached Files Attached Files

  7. #7
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: vb to word problem

    I'm sorry, I can't reproduce your problem.

    Can you make a new project which just has a multiline text box with the kind of data you're talking about and writes the data in the textbox to a Word document when you click a button?

    If you get the same problem with this new project then post the code for it.
    This world is not my home. I'm just passing through.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    Re: vb to word problem

    Hii

    i have a multiline textbox i:e Text1(7) and the data that comes in that textbox is from an access database Example:

    the data is in access database & i take that data into an array and split it and then put that in the multiline textbox with a crlf at the end and thats hows there is a line in the textbox and then a blank line and then again a line of text.

    Then to transfer the data to a work file in the program it finds a word "bkH" & replaces that word with the data that is in the Text1(7) [multiline textbox] thats it.

    And this program that is attached is called when i click on the save button.
    pls help me regarding this its very urgent or tell me how can i transfer the data to the word file from vb.

  9. #9
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: vb to word problem

    This works for me. What are you doing different that causes a problem?

    VB Code:
    1. Private Sub Command1_Click()
    2.   Set appwd = CreateObject("Word.Application")
    3.   appwd.Visible = True
    4.   appwd.Documents.Open "c:\others.doc"
    5.   appwd.selection.typetext Text1.Text
    6.   appwd.ActiveDocument.SaveAs "c:\others.doc"
    7.   appwd.ActiveDocument.Close
    8.   appwd.Quit
    9.   Set appwd = Nothing
    10.  
    11. End Sub
    12.  
    13. Private Sub Form_Load()
    14.   Text1.Text = Text1.Text & "line1" & vbCrLf
    15.   Text1.Text = Text1.Text & "line2" & vbCrLf
    16.   Text1.Text = Text1.Text & "line3" & vbCrLf
    17.   Text1.Text = Text1.Text & "line4" & vbCrLf
    18.   Text1.Text = Text1.Text & "line5" & vbCrLf
    19.   Text1.Text = Text1.Text & "line6" & vbCrLf
    20.   Text1.Text = Text1.Text & "line7" & vbCrLf
    21. End Sub
    This world is not my home. I'm just passing through.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    Re: vb to word problem

    this will be only for 1 textbox where as i have 8 textbox's and i want to transfer the data from all the textbox's to the word file then in that case how will it work.

  11. #11
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: vb to word problem

    The example I've given is a response to your initial question. You said you had a problem with "small boxes" when you transferred data from a multiline textbox to Word.

    I want to understand why this works for me but not in your application.

    Are you asking for a complete solution now?
    This world is not my home. I'm just passing through.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    Re: vb to word problem

    yes if you could pls give me a complete solution for then that would be gr8

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    179

    Re: vb to word problem

    hii trisuglow

    the code that u gave me did worked but how can i make it work with more then 1 text box.
    could you pls help me complete solution.

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