UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Export To Word In Preview Not Print All, Access 2016    
 
   
claven123
post Sep 7 2019, 07:43 PM
Post#1



Posts: 87
Joined: 7-January 11



I would like to export to word (form letter) and preview the print job before printing. I have it set up to automatically print the letters (>70), but would like the ability to preview them before printing.

This is the code I have set up thus far.
CODE
           ' wDoc.PrintOut , acPrintAll
            wDoc.PrintOut , acViewPreview


I had the top line,,,,, acPrintAll which does work, I tried the second line acViewPreview but got an error.

Error Number: 9118=parameter value was out of acceptable range.

CODE
snip    
    Set wApp = New Word.Application
    Set wDoc = wApp.Documents.Open(CurrentProject.Path & "\ExportLetterANNUALDINNER.docx")
    Set rs = CurrentDb.OpenRecordset("AddressLabelCurrent", dbOpenDynaset)
        
    If Not rs.EOF Then rs.MoveFirst
        Do Until rs.EOF
            wDoc.Bookmarks("FullNameBook").Range.Text = Nz(rs!Name, "")
            wDoc.Bookmarks("StreetAddressBook").Range.Text = Nz(rs!StreetAddress, "")
            wDoc.Bookmarks("FullAddressBook").Range.Text = Nz(rs!FullAddress, "")
            wDoc.Bookmarks("ShortNicknameBook").Range.Text = Nz(rs!ShortNickname, "")
            'wDoc.SaveAs2 CurrentProject.Path & "\" & rs!StreetAddress & "_documentname.docx"
            
           ' wDoc.PrintOut , acPrintAll
            wDoc.PrintOut , acViewPreview
            wDoc.Bookmarks("FullNameBook").Range.Delete wdCharacter, Len(Nz(rs!Name, ""))
            wDoc.Bookmarks("StreetAddressBook").Range.Delete wdCharacter, Len(Nz(rs!StreetAddress, ""))
            wDoc.Bookmarks("FullAddressBook").Range.Delete wdCharacter, Len(Nz(rs!FullAddress, ""))
            wDoc.Bookmarks("ShortNicknameBook").Range.Delete wdCharacter, Len(Nz(rs!ShortNickname, ""))
snip
Go to the top of the page
 
June7
post Sep 7 2019, 08:47 PM
Post#2



Posts: 891
Joined: 25-January 16



As far as I can tell, acViewPreview is not a parameter of PrintOut method. It is for OpenReport.

I am surprised acPrintAll works because looks like it is in wrong argument position.

Word PrintOut and Access PrintOut have different arguments.
https://docs.microsoft.com/en-us/office/vba...cument.printout
https://docs.microsoft.com/en-us/office/vba....DoCmd.PrintOut

Perhaps instead of PrintOut you need:

wdoc.PrintPreview

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
claven123
post Sep 7 2019, 09:29 PM
Post#3



Posts: 87
Joined: 7-January 11



I placed that in the code, it did not do anything.

CODE
wdoc.PrintPreview


I don't think it can show a preview and then go to the next record set and end up showing 70 or 80 previews.

Initially, I had it create a file for each one, then you'd have to open each one to print it. Which would work, but not very nice.

I wonder if there is a way to print all docs in a folder?

D
Go to the top of the page
 
claven123
post Sep 7 2019, 09:31 PM
Post#4



Posts: 87
Joined: 7-January 11



Yes, there is, so this might be the solution, to save them in a folder and print them from there.

D
Go to the top of the page
 
claven123
post Sep 7 2019, 10:00 PM
Post#5



Posts: 87
Joined: 7-January 11



CODE
wDoc.SaveAs2 CurrentProject.Path & "\" & rs!StreetAddress & "_documentname.docx"


How do I designate another folder IN the currentproject.path directory, say /PrintThese

I can't seem to get the syntax correct.

D
Go to the top of the page
 
claven123
post Sep 7 2019, 10:25 PM
Post#6



Posts: 87
Joined: 7-January 11



Got it to work.

CODE
wDoc.SaveAs2 CurrentProject.Path & "\PrintInvites" & "\" & rs!Name & "_AnnualInvite.docx"


d
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    23rd October 2019 - 09:01 AM