View Single Post
 
Old 05-30-2018, 03:03 PM
kiwimtnbkr kiwimtnbkr is offline Windows 10 Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2017
Posts: 69
kiwimtnbkr is on a distinguished road
Default

Quote:
Originally Posted by slaycock View Post
Try adding the ranges option to the printout statement. The help for the printout statement isn't entirely clear as both the pages and range option are 'optional'. It doesn't state that ranges must be set if pages is used but its worth a try.

If fields are not updating at print then something is odd. We can try to rectify this by updating fields in the document before printing each copy as in your original code.

Replace the print loop with the following and let us know how you get on.

Code:
    For copy_number = first_copy To last_copy
        With ActiveDocument
            .CustomDocumentProperties(cdp_name) = CStr(copy_number)
            .Fields.Update
            .PrintOut copies:=1, Range:=wdPrintRangeOfPages, pages:=my_form.txtPages.Value
        End With
    Next
I checked this by printing to pdf on on my pc and all works as expected. It may not work for you if your field is in a header or footer.
The print functionality is now working absolutely bang on - THANK YOU!

However, whilst the fields (read serial number fields) are updating as excepted and always have been (sorry I think I've added to the confusion here), the links aren't. The idea behind the links updating is to make sure that the embedded tables in the document are updated with the latest information from the spreadsheet that it is linked to prior to printing.

I've gone back to my very original code and confirmed that the updating of the links still works which it does so I'm at a loss as to why your code with contains pretty much the same coding doesn't run the updating of the links.

Still happy to share the word doc and spreadsheet workbook if necessary.

EDIT - have now got the embedded tables in the document updating as expected when printing the entire document by adding 'Activedocument.Fields.Update' before the 'ActiveDocument.Printout Copies:=1' line of code.

Worked as expected when printing just selected pages from the document so initially had me scratching my head but the answer was obvious when I stepped back and had a proper look.

Now to put it into the production environment and check that it works as I expect it to.

Last edited by kiwimtnbkr; 05-30-2018 at 05:42 PM.
Reply With Quote