Results 1 to 2 of 2
  1. #1
    Ron is offline Novice
    Windows 10 Access 2007
    Join Date
    Sep 2020
    Posts
    5

    VBA Word Adding Table and Moving Cursor to End of Table

    Hi,

    This should be very simple but I have literally spent two hours trying to add a line break after a table then set the word range to the current cursor location. Can someone please guide me out of this wormhole. I know it is extremely simple but I am a hack. Thanks. Ron

    Code:
    'Active Loop Start
     
    Set wdRng = .Bookmarks("Active").Range
     
        Do While Not QueryM.EOF
     
    '>>>>>I need to set the wdRng to current cursor location here??<<<<<
    
       ‘Insert Table
        'Set wdtbl = .Tables.Add(Range:=wdRng, NumRows:=1, NumColumns:=6, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
         
                'With wdtbl
                .Style = "Table Grid"
                .ApplyStyleHeadingRows = True
                .ApplyStyleLastRow = False
                .ApplyStyleFirstColumn = True
                .ApplyStyleLastColumn = False
                .ApplyStyleRowBands = True
                .ApplyStyleColumnBands = False
                .Borders(wdBorderLeft).Color = -603930625
                .Borders(wdBorderRight).Color = -603930625
                .Borders(wdBorderTop).Color = -603930625
                .Borders(wdBorderBottom).Color = -603930625
                .Borders(wdBorderVertical).Color = -603930625
                     
                    With .Cell(1, 1).Range
                       .InsertAfter QueryM![DA Prefix] & QueryM![Year] & "/" & QueryM![DA No]
                    End With
       
    ‘>>>>>>I would like move the cursor to the end of the table and  add a paragraph break after the table so that then next table will be placed after the previous one. But I don’t know how?? I can't use move to last character as it is not at the end of the document.<<<<<
    
                End With
            QueryM.MoveNext
    
    'Active Loop Ends
        Loop
               
        QueryM.Close


  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Your question is about Word vba? You might get lucky but there isn't even a Word forum at this site (as far as I can see). You might be better off posting your question in a Word forum.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 4
    Last Post: 05-30-2020, 06:19 AM
  2. Replies: 4
    Last Post: 01-16-2019, 03:38 AM
  3. Word table to Access table problem
    By Euler in forum Import/Export Data
    Replies: 2
    Last Post: 03-02-2017, 02:26 PM
  4. Replies: 1
    Last Post: 03-05-2013, 02:37 PM
  5. Replies: 5
    Last Post: 04-12-2012, 05:20 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