Consulting

Results 1 to 4 of 4

Thread: Preserve formatting after update - WORD Table

  1. #1

    Question Preserve formatting after update - WORD Table

    Hi

    I am new on here so I hope I have posted this in the right place.

    I have some VBA code that takes a table + title in specific cell + source information in another cell in Excel and pastes it into Word using the 'Link and keep source formatting' option.

    This works fine getting the table and other informatin into word, however when the links are updated the formatting goes all over the place.

    I ran some tests and I believe that if the 'Preserve formatting after update' box is checked in Word for each table then this retains the formatting. The only way I have found to do this in the code is when it is first pasted into word, but this doesn't retain the formatting from the Excel file.

    Basically I think what I am looking for is a piece of code that can be tagged on the end of what I have already that checks the 'Preserve formatting after update' box after everything else has happened.

    Can anyone help with this please?

    Thank you
    Jo

  2. #2
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    Welcome to VBAX Jo. Please be patient and someone will be along shortly to assist you. BTW, you posted in the Site and Forum related sub forum, but I have moved this to the correct forum.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    Bump
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    Hmmm.. I would have thought one of the Word guru's would have been by, by now. Okay I went searching and found this piece of code which might give you a hint
    Sub TestMemoGen()
    Dim objWord As Object
    Dim ws2 As Worksheet
     
    Application.ScreenUpdating = False
    Set ws2 = ThisWorkbook.Sheets("Word Export")
    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True
    objWord.Documents.Open "C:\Users\ Tester\Word Test Sim.docm"
     
    With objWord.ActiveDocument
    .Bookmarks("DENT_90").Range.Text = ws2.Range("DENT_90").DisplayFormat.NumberFormat
    End With
    Set objWord = Nothing
    Application.EnableEvents = True
    End Sub
    Not having any experience in word VBA, I don't know if this works.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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