Consulting

Page 1 of 4 1 2 3 ... LastLast
Results 1 to 20 of 79

Thread: Printing macro - impossible?

  1. #1

    Printing macro - impossible?

    Hello to everyone!

    Now this is a hard one, since I couldn't find the answer anywhere on this forum.
    Old version of Word (2003), and there is a need for the macro which would do the following:

    Print 10 pages of a document "A", but the 10th page would be printed duplex, so that the back side of that page would be a pre-written document saved in, for example c:\documents\document1.doc.

    So that document1.doc should be a back side of a 10th page printed in duplex.

    With the macro activated, 9 pages would print normally, but the 10th page would print a duplex side from the document1.doc file and then the front from the document "A".

    Let's say that the duplex is being printed in Tray2.The rest is Tray1.

    No idea how to do this and no references on the internet that could be of any help whatsoever.

    Thanks for the help in advance!

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi Zac,

    The basic approach would be to print the first 8 pages as one simplex job, then the last two pages as a separate duplex job. To do this, though, the pages for the duplex print need to be combined into a single document.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Hi macropod,

    that's not exactly what I had in mind.

    I would need the last page to be always the front page of the C:\documents\document1.doc.

    No matter how many pages I would print, 10,11 or 25, the last one in order should always be duplex with the page from C:\documents\document1.doc as it's backside.

    Now, I know it is possible to record some stuff, but so far I had no success in accomplishing this. It probably requires some VBA programming which is extremely hard.

    Example: printer would print 9 pages normally, then stop, print the last page (10th for example) as duplex combined with the 1st page from C:\documents\document1.doc

    When I look at this, it does look really complicated lol.

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    hi Zack,

    It's not that hard to program, but programming might not be necessary anyway. As an alternative to programming, you could use an INCLUDETEXT field to pull the 'last' page document's content into the main document and use a bit more field coding to ensure that always appear on an even page. You could then print manually in two passes - or you could use a macro just for the printing part.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Well, it is hard when the macro itself has to work for every last page of every document I want to open. It has to recognize that "last page" automatically.
    Even with the INCLUDETEXT I don't know how to set it properly to appear every time I run the macro. So that the text would be printed automatically on the same page (but different side / duplex) of the last page of the every document I want to.
    If someone knows how to program that I would appreciate it. If it's impossible then some alternative solution perhaps?

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Inserting another file via an INCLUDETEXT field is fairly easy. The field code to control which page of your document is also fairly easy. IF fields coded as:
    {IF{=MOD({PAGE},2)}= 1 {QUOTE 12}}
    or:
    {IF{=MOD({PAGE},2)}= 1 "{QUOTE 12}¶
    This page intentionally left blank¶
    "}
    respectively, will automatically insert a blank page if the page on which they occur is an odd-numbered one.

    To get the same effect for an even-numbered page, change the '1' to '0'.

    Such a field would be used with ordinary 'Next Page' Section breaks to separate chapters, etc., and placed immediately before the final '¶' symbol (paragraph break) on the page concerned (ie immediately before the 'Next Page' Section break).

    Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  7. #7
    So it is impossible to write a working macro that would help my issue..

  8. #8
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    I didn't say that. What I have said is that whatever pages you want duplexed have to be part of the same document. You seem unwilling to accept that little fact.

    Furthermore, I've showed you how you can use an INCLUDETEXT field to import another document's content, plus an IF field to ensure the imported content appears on the correct page. That will be the simplest way of achieveing the desired outcome, regardless of whether a macro is used.

    If you're not willing to do at least that much, to achieve the requirement to have the print job coming from a single document, what's the point of anyone writing a macro? On top of that, printer commands for tray selection & duplexing are often printer-specific and you'll need to provide the relevant details before anything could be coded.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  9. #9
    Didn't know that about the printer, sorry about that.

    This IF field you are talking about - I simply do not understand what you are saying. It all sounds too abstract, for me. INCLUDETEXT field is something that I do understand, however I don't know how to incorporate it into macro so I don't have to enter it manually each time for the every document I want to implement it with. That's the reason why I was wondering if such macro is possible to create. I know that you don't have time busting your head with such weird macros, but I don't know any other forum where I could get this sort of help.

    If it's the question of money, tell me the price.

  10. #10
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Not to answer for Paul... but it is almost *always* a question of time. Which, depending on the person, equates to money (more or less). Paul is trying to give you a direction to look in, because the specific answer is actually impossible to give you (since it is related to printer driver/printer configuration stuff).

    But the short answer is-- if you understand how to use an INCLUDETEXT field, and you know how to use Autotext (or Building Blocks, depending on your version), it is fairly trivial to insert something at the end of the document and then modify contents of that field via macros.

    But you have to set all that up, and see if you can get that working as a proof-of-concept sans-macros in your environment before any code automating the process can be given to you... short of hiring a developer to work in your environment to actually deliver it to you.

    You will almost always end up paying someone (or completing it yourself) for things specific to printer trays/duplex printing, because unless someone has the exact same driver set (and printer configuration-- even extra paper trays on the same printer can cause issues), it becomes very difficult to deliver more than proof-of-concept code related to printer settings (since, as Paul said, those are 99% of the time printer driver specific).

    Everything is possible, and some of this is even easy (when you know the answer, of course), but the delivery is tough on this forum.

    Note: I'm not volunteering my services as a paid consultant-- I'm plenty busy anyway, just trying to help you understand.

  11. #11
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by Zack
    This IF field you are talking about - I simply do not understand what you are saying. It all sounds too abstract, for me. INCLUDETEXT field is something that I do understand, however I don't know how to incorporate it into macro so I don't have to enter it manually each time for the every document I want to implement it with.
    You don't have to understand these things to use them. Most people can drive a car without understanding how internal combustion engines work. Have you at least tried to add the IF & INCLUDETEXT fields to one of your documents so that you can see them in action?
    That's the reason why I was wondering if such macro is possible to create. I know that you don't have time busting your head with such weird macros, but I don't know any other forum where I could get this sort of help.
    Yes, I could write a macro to add the IF & INCLUDETEXT fields to a document - but I know nothing of what the INCLUDETEXT field's code would be, since I know neither the document's name nor it's path. Furthermore, I'd need to know whether it has the same page layout as the document it's to go in and whether the source document has its own header & footer that needs to be replicated in the target document or whether the target document's header & footer should be retained. Frankly, if all of this is for documents based on a couple of templates, it'd be far simpler to implement and maintain by doing it manually.
    If it's the question of money, tell me the price.
    For me, it's not a matter of money. But I'm not about to spend a lot of time developing a macro to do something that can done more simply by another means. In any event, for the reasons Frosty has given, it'd be difficult for anyone without physical access to your printers, or others like them, to do the printer-specific coding.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  12. #12
    Quote Originally Posted by Frosty

    Everything is possible, and some of this is even easy (when you know the answer, of course), but the delivery is tough on this forum.
    I don't understand. Why would the delivery be tough?

  13. #13
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Zack,

    I meant that delivery of a 100% completed macro by (somewhat) anonymous internet posters is tough on the forum because, as Paul said, it's difficult without access to your printers (whether that is physically being onsite, or remotely accessing your machine and all the security questions that kind of access would raise).

    In short, with the constraints of just getting your info from a forum... you can only get part of the way there.

    But none of this is really helping you solve your problem. If what Paul posted to try is not somethig you are able to absorb and attempt, you may need to hire someone.

  14. #14
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Zack, it would definitely be worth your effort to try and get the INCLUDETEXT to work, at least once. Try. If it does not work exactly as you want, post precisely what is not working.
    This IF field you are talking about - I simply do not understand what you are saying. It all sounds too abstract, for me. INCLUDETEXT field is something that I do understand
    The problem is that what you are giving us is too abstract, which Paul has been trying to state clearly.

    So. TRY something with the includetext field. Even forget about the IF part to start.

    {IF{=MOD({PAGE},2)}= 1 {QUOTE 12}}
    or:
    {IF{=MOD({PAGE},2)}= 1 "{QUOTE 12}¶

    This is just a way to determine the page the field is on is even or odd numbered. So forget about it for now. TRY something first.

  15. #15
    Quote Originally Posted by fumei
    Zack, it would definitely be worth your effort to try and get the INCLUDETEXT to work, at least once. Try. If it does not work exactly as you want, post precisely what is not working.The problem is that what you are giving us is too abstract, which Paul has been trying to state clearly.

    So. TRY something with the includetext field. Even forget about the IF part to start.

    {IF{=MOD({PAGE},2)}= 1 {QUOTE 12}}
    or:
    {IF{=MOD({PAGE},2)}= 1 "{QUOTE 12}¶

    This is just a way to determine the page the field is on is even or odd numbered. So forget about it for now. TRY something first.
    There is a document in C:\docs\jiggle\wave.doc

    When I print a document I want it to determine it's last page (regardless of how many pages it has, 15,20 or 50) and then add an extra page with a content of C:\docs\jiggle\wave.doc

    Or

    If the document has 20 pages I want a macro which would print all 20 pages and the page from C:\docs\jiggle\wave.doc, as 21'st page in one printing job.
    Which means it has to determine the number of the last page and print one extra more from C:\docs\jiggle\wave.doc content.

    I tried {IF{=MOD({PAGE},2)}= 1 "{QUOTE 12}, but I don't see how could it resolve my issue.

  16. #16
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    I don't see any evidence that you've actually tried using the INCLUDETEXT field. Furthermore, if you used the IF field, the results would only be apparent if its rules determine that an empty page needed to be inserted before the page imported via the INCLUDETEXT field. This is something it will only do when an event like printing the document (or Ctrl-A, F9) causes the fields to update. BTW, you need to set Word's 'update fields before printing' option.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  17. #17
    {INCLUDETEXT "C:\\documents\\document1.doc"}

    Then I update with
    [VBA]Dim aStory As Range
    Dim aField As Field

    For Each aStory In ActiveDocument.StoryRanges
    For Each aField In aStory.Fields
    aField.update
    Next aField
    Next aStory

    End Sub[/VBA]

    Says that I don't have bookmark specified. Since I don't know what a bookmark in INCLUDETEXT should be, I googled for it.
    Then I entered:

    {INCLUDETEXT "C:\\documents\\document1.doc" "huh"}

    Updated and still says I don't have a bookmark.

    When I look at this: {IF{=MOD({PAGE},2)}= 1 "{QUOTE 12}

    I don't know which values should I change? QUOTE just stays qoute? Page stays page? How does it relate to {INCLUDETEXT "C:\\documents\\document1.doc"} ?

    None of this works.

  18. #18
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    For the IF field, did you create all the field-brace pairs via Ctrl-F9, as per my note in post #6?

    Your INCLUDETEXT field does not need a bookmark reference unless you only want to import a bookmarked range from the source document.

    Provided you've set Word's options to update fields before printing, you don't need the macro.

    Based on what you've posted so far, all you need is two consecutive field sets:
    {IF{=MOD({PAGE},2)}= 1 {QUOTE 12}}{INCLUDETEXT "C:\\documents\\document1.doc"}
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  19. #19
    But how does it delete a header from that page alone? Not touching previous 40 pages with pre-defined header?

  20. #20
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    But how does it delete a header from that page alone? Not touching previous 40 pages with pre-defined header?
    Well...it does not. Why would it? You have NEVER mentioned anything AT ALL about a header. Please try to stick with what you actually ask.

    I fear you do not understand how headers work either. If any page has a different header they MUST be separated by a Section break. If you are now asking - out of the blue - for something to add a Section break then yes, fields will not work. You would need VBA to add the Section break.

    OR, just do it yourself. If you are not going to show some evidence that you are actually trying to do something yourself, it may be best if you just do what you want manually.

    I am not even sure what you mean by "pre-defined header". I am assuming what you mean is that there IS a header - which has nothing pre-defined about it.

Posting Permissions

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