Results 1 to 4 of 4

Thread: [RESOLVED] [vb6] How to insert a tabspace in Word Object?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2012
    Location
    La Plata, Buenos Aires, Argentina
    Posts
    52

    Resolved [RESOLVED] [vb6] How to insert a tabspace in Word Object?

    Hi.

    I have a textbox that I filled like this:
    Code:
    TextBox = "1" & vbtab & "2" & vbNewLine _
                & "3333" & vbtab & "4"
    (I previoulsy fixed the tabs positions, but that doesn't matter here)

    Now I open a template file in Word Object, set like this:
    Code:
    Public Obj_Word As Object
    Set Obj_Word = CreateObject("Word.Application")
    and pass that textbox to the file, but the columns does not stick to the tabs in the word. In the example I wrote here, the output would be: numbers 2 and 4 not in the same horizontal space.

    To be clear, my only problem is: The tabs (perfectly shown in textbox) are gone in Word. How do I insert a tabspace character in Word?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [vb6] How to insert a tabspace in Word Object?

    did you try replacing vbtab with ^t ?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    PowerPoster
    Join Date
    Oct 2010
    Posts
    2,141

    Re: [vb6] How to insert a tabspace in Word Object?

    Please show the code snippet where you set the Word text. This does not make sense as this VBA code inserts tabs.
    Code:
    Private Sub UserForm_Initialize()
       TextBox1.Text = "1" & vbTab & "2" & vbNewLine & "3333" & vbTab & "4" & vbNewLine
    End Sub
    
    Private Sub CommandButton1_Click()
       Dim para As Paragraph
       Set para = ActiveDocument.Paragraphs.Add
       para.Range.Text = TextBox1.Text 
    End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    May 2012
    Location
    La Plata, Buenos Aires, Argentina
    Posts
    52

    Re: [RESOLVED] [vb6] How to insert a tabspace in Word Object?

    Apparently, the tabspace were right, they were succesfully passed from the textbox to the Word Object. The tabspaces didn't match my previously-set tabs in Word because I was setting them inside the frame, instead of globally, outside the frame.

    Sorry, my mistake.
    Thank you.

Tags for this Thread

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