Results 1 to 2 of 2
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Adding a table to word document then strings thereon

    Hi Guy's, can i ask where i can add a table to word document

    I don't have a problem with it as it is but would like to tidy it more



    the document has got a logo at the top so choosing to move down to paragraph 12 with increments of 2 afterwards

    I have commented out where i have tried and trying to set the table after with oWord then commented back out again

    all strQ1 to strQ14 are a string of questions

    all pipes | are replacing vbnewlines and all back slash \ are replacing with vbtabs

    so im trying to add a table and add strTitle and Date to table with 2 columns

    something else i am going to try is have each strQ1 to 14 in their own tables so the strQ's questions are in column 1 of the table and columns 2 would be where we would comment

    I believe setting the wd (word document) is not right

    also believe i need to add new tables between strQ's (each question)

    what is your thoughts ? ps not using debug.print because i think my problem is setting correctly and method ????

    not posted all but just the part i'm asking for help on the method

    Code:
     wdPath = "T:\DMT Ltd\Word Docs\"    strPath = "T:\DMT Ltd\Word Docs\Inverviews\"
        wdFile = "Questionaire Front Page.docx"
    
        strInput = INputBox("Enter Applicants Name ?")
    
        strTitle = vbTab & "Interview: " & strInput & "|"
    
    
        Set oWord = CreateObject(Class:="Word.Application")
        oWord.Visible = True
        oWord.Documents.Open Filename:=wdPath & wdFile
        'Form here Add Table
       ' Set wd = oWord.Documents.Add(wdPath & wdFile, , , True)
        
       ' With oWord
        'Set wdTbl = wd.Tables.Add(wd.Paragraphs.Add(wd.Paragraphs(12).Range).Range, 1, 2)
        '    wdTbl.Borders.Enable = True
        '        With wdTbl.Range.Font
        '        .Name = "Times New Roman"
        '        .Size = 11
        '        End With
       ' Set wdRw = wdTbl.Rows.Add()
       ' wdRw.Cells(1).Range.Text = strTitle
       ' wdRw.Cells(2).Range.Text = Format(Now(), "dddd-dd-mmm-yyyy")
        
        'To Here
        With oWord
        oWord.selection.MoveDown unit:=wdParagraph, Count:=14
            oWord.selection.Text = Format(Now(), "dddd-dd-mmm-yyyy")
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(strTitle, "|", vbNewLine & vbNewLine)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = strLine & vbNewLine
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ1, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ2, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ3, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ4, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ5, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ6, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ7, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ8, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ9, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ10, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ11, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ12, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ13, "|", vbNewLine & vbNewLine), "\", vbTab)
        oWord.selection.MoveDown unit:=wdParagraph, Count:=2
            oWord.selection.Text = Replace(Replace(strQ14, "|", vbNewLine & vbNewLine), "\", vbTab)
    End With
    
    
    
    
    Set oWord = Nothing
    
    
    
    
    Application.FollowHyperlink wdPath & wdFile

  2. #2
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191
    Durr just make a template and find the paragraph to add name and date!!!!!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 04-05-2022, 10:05 PM
  2. Replies: 3
    Last Post: 06-27-2017, 12:06 PM
  3. Move OLE Object from Access table to a Word Document
    By sneuberg in forum Programming
    Replies: 2
    Last Post: 07-18-2015, 11:55 AM
  4. Replies: 1
    Last Post: 01-24-2014, 01:21 PM
  5. Replies: 3
    Last Post: 06-11-2013, 07:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums