Consulting

Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 41 to 60 of 79

Thread: Printing macro - impossible?

  1. #41
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    As an example... You probably don't know that you can print specific pages. Have you recorded a macro in which you manually printed pages 9 and 10 of a 10 page document? No? Well, if you had tried, then you would be closer to asking the right questions.

    But you have to either A) be a part of the solution or B) pay someone so that you don't have to be a part of the solution. That's generally the way it works.

  2. #42
    Quote Originally Posted by Frosty

    The above code does not do what you say it does, obviously.
    The thing I thought it does is the very same thing I've been kindly asking for numerous times already. When I asked him about the code and could it somehow be used in a way that I previously described it should, Fumei himself said, and I quote him on that:"That is EXACTLY what I posted!" After some time of using the code I realised that he was right. I just didn't pay much attention to the macro and the way it can be used. So it was my fault alone.

    I've also posted an attempt of mine while recording a macro, which was really far less efficient compared to the one that Fumei wrote. I can't emphasize enough my gratitude for the help that I was provided with so far.
    Last edited by Zack; 04-29-2012 at 01:26 PM.

  3. #43
    Quote Originally Posted by Frosty
    As an example... You probably don't know that you can print specific pages. Have you recorded a macro in which you manually printed pages 9 and 10 of a 10 page document? No? Well, if you had tried, then you would be closer to asking the right questions.

    I apologize for the absence of sense in my previous attempts of asking the right questions, it is probably due to the fact that English is not my native language.

    The problem lies in the premise that I need a macro only for the one specific document with certain number of pages. Accordingly, a logical conclusion would be that in this particular case a solution lies in pressing ctrl + p and selecting the range of pages that I would like to print.

    Think for a minute of a solution that can be applied to each and every document, regardless of the number of their pages. In the layman's terms, a way to recognize the last page and the page that precedes it. I wish I had more computer knowledge to use the proper terms, but I am trying my best to describe the general idea of how something should work.

    P.S. I appreciate your time and effort.
    Last edited by Zack; 04-29-2012 at 01:43 PM.

  4. #44
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Think for a minute of a solution that can be applied to each and every document, regardless of the number of their pages. In the layman's terms, a way to recognize the last page and the page that precedes it. I wish I had more computer knowledge to use the proper terms, but I am trying my best to describe the general idea of how something should work.
    I can not believe I am reading this.

    Document A: 14 pages.
    As I posted
    1. calaculate the number of pages ( x = 14)
    2. add new page with new document inserted. (number of pages now x + 1)
    3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1

    Document B: 4,678 pages
    1. calaculate the number of pages ( x = 4678)
    2. add new page with new document inserted. (number of pages now x + 1)
    3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1

    Notice something? Nothing changes in terms of calculating. BOTH douments use the same calculation.

    You do not need computer knowledge. You need Grade 4 math.

    Get the total number of pages (x)
    You add a page with the inserted document.
    PRINT 1 to x-2
    PRINT x-1 to x + 1 (the last two pages)

    This applies to ANY document. Be it 14 pages or 4678 pages. As I posted - basic logic. If you can not see this basic logic after I posted it three times, I suggest you really do hire someone. If you came up with a real question - how DO I get the number of pages? - I would have helped get you the answer.
    I am trying my best to describe the general idea of how something should work.
    And you have been told how something should work.

  5. #45
    Quote Originally Posted by fumei
    I would have helped get you the answer.
    3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1

    Putting this in VBA would help me a lot.

  6. #46
    Quote Originally Posted by fumei
    I would have helped get you the answer.
    3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1

    Putting this in VBA would help me a lot.

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

    Here is what you should do.

    1. Set up a 3 page dummy document.
    2. Use Include Text to insert text from another document at the end of this document
    3. Put a section break in front of the IncludeText field.
    4. Use Page Setup to attempt to print the last page of the document as duplex.
    5. Play around with settings until you have a document which prints the way you want it to (a SINGLE document).
    6. Post that dummy document, and ask questions about how to automate the process.

    There is NO EASY VBA ANSWER for this. Trust us. You need to do some leg work to manually set up your document. I have not used the field codes Paul/Macropod posted before. I was able to make a document which worked somewhat by following his instructions.

    I am posting that document. What I see happens is that if I insert an additional page before the complex IF field code, then a page break (that is the QUOTE 12 portion of the field code) is inserted.

    This means that, no matter how many pages my document has, I will ALWAYS be printing out an even number of pages. This *seems* to me to be something that could ultimately be part of your solution, based on what you have said.

    However, I don't know this-- only you can answer. But you have to try first, please.

    There is no VBA code out there to solve your problems. Only understanding which you currently lack and we are trying to provide.
    Attached Files Attached Files

  8. #48
    Quote Originally Posted by Frosty
    This *seems* to me to be something that could ultimately be part of your solution, based on what you have said.
    fumei wrote:"3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1"

    If it's impossible to make a VBA of this then ok. Since you are a VBA expert I will believe you.

    I am grateful for your aid so far and as I said, I learnt a lot about the Word and macros by following your instructions. I will set the document manually, see where it gets me, find a substitute to what needs to be done and if nothing I will just point and click where needed. I understand that certain issues are just too complicated to solve and that no one has answers for everything. When people in my profession ask me things I don't know, or I can't answer with an adequate amount of info, I usually direct them to those who can be more helpful than me. Pretending to know the answer just for the sake of my ego would be foolish. In a way I respect you for being honest.

  9. #49
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    fumei wrote:"3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1"

    If it's impossible to make a VBA of this then ok. Since you are a VBA expert I will believe you.
    On the contrary, it is not only VERY possible...it is VERY easy. So I am not going to post it. YOU do it.

    Again, you have not shown a single piece of effort.

    If you do not get it exactly right, that is OK. Post what you tried and THEN I (or someone else) will help you fix it. But man up and at least try. It is NOT hard at all. Most of the people who have put code here could do it in under 30 seconds.

  10. #50
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Well, to be fair... There are 10+ ways to accomplish this task, all of which represent "easy" VBA code, and all of which will be "wrong" or "break" in specific other scenarios.

    And in the absence of more information, giving the "right" answer for you scenario is impossible

  11. #51
    Quote Originally Posted by fumei
    On the contrary, it is not only VERY possible...it is VERY easy. So I am not going to post it. YOU do it.
    I don't know VBA that well. If I knew, I wouldn't be asking for assistance on this forum. As I said Fumei, you don't have to help me, but try not to hinder me from getting a solution. I always thought that knowledge should be freely shared with others, but I respect if someone has abundance of it and does not want willingly to give away years of experience. Maybe people think differently in Europe, I don't know. There's a lot of ambivalence on this forum. First someone says that something is impossible, then someone else says that it's not only possible, but fairly easy to accomplish etc. It is all very confusing. I'm sure you are very good in what you do and I don't want anyone to think otherwise just because we've been exchanging words over a trivial matter. All the best to you.

  12. #52
    Quote Originally Posted by Frosty
    And in the absence of more information
    3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1"


    What other information do you require Frosty?

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

    Same info I've been asking for the same time. You posting a document and some macros where you've tried some of the approaches suggested in this thread.

    You posted a document in the other thread... but there were no field codes in it, no explanation of what you had attempted using that document, what hadn't worked.

    The VBA code may or may not end up being easy, may or may not end up being right. However... VBA is the *last* step. The first step is-- how do you currently (MANUALLY) do this process now?

    Does manually putting in "S2 P6" in the print dialog not work for you? Any ideas why it doesn't? How is your page numbering set up? Do you reset page numbering at a different section?

    Basically, the fact that you're asking a question means you don't know the answer. The fact that you haven't yet gotten an answer means we don't know the answer either. So, the only difference between us and you is that we have a better methodology (because of our familiarity) of trying to find the answer.

    I am, at least, trying to help you learn how to find out the answer yourself (since neither you nor I know it). Especially since, with printers, a lot of the "solving" may very well have to do with something specific about the printer and/or the version of Word you are using.

    So... more information:
    1. What have YOU tried thus far (people posting code and you saying "no, didn't work" is not helpful).
    2. What version of Word you are using.
    3. A dummy document which contains multiple section breaks (if you care about section breaks, which it seems you do) as well as what MANUAL steps you would need to perform in order to get that document to print.

    i.e., I don't want to waste time posting things analogous to "is your printer plugged in? is your computer plugged into your printer? Can your printer currently perform duplex printing? Do you have to manually insert the pages in order to duplex print, or does it duplex print for you? Is your printer toner/ink full?"

    Most basic troubleshooting comes down to step1: seeing how far the end-user can get himself or herself. Your lack of knowledge about VBA is immaterial. That's totally fine. Your inability to ask the right question is immaterial. What's making this more difficult is that you aren't really paying attention (personality clash with Fumei aside) to what is being posted.

    The very first suggestion in this thread had merit. Yet all things point to you neither trying it nor explaining why you didn't want to try it apart from "it seems abstract."

    This is the danger in determining the solution without understanding the problem. VBA may not be the answer here. You may be able to, at the end of the day, simply have some fieldcodes you can paste into the document, with some appropriate formatting, which handle ALL of what you want. And you could store that information in an autotext entry, and then the only VBA necessary would be something along the lines of...

    [vba]
    Sub MagicMacro
    dim rngWhere as Range
    set rngWhere = ActiveDocument.Content
    rngWhere.Collapse wdCollapseEnd
    Application.Templates("C:\MyTemplate.dot").BuildingBlockEntries("MyEntry"). Insert where:=rngWhere, RichText:=True
    ActiveDocument.PrintOut
    End Sub
    [/vba]

  14. #54
    Quote Originally Posted by Frosty
    Does manually putting in "S2 P6" in the print dialog not work for you? Any ideas why it doesn't?
    Manually putting section and the page I want to print works, but that is not the solution because it has to AUTOMATICALLY determine the last page and print it out. Of course, for the specific section. Lets assume that the document I've posted has 20 pages, and the other one would be the same but with 15 pages. It can also have 50 or 55 pages, it really doesn't matter. What matters is that the VBA automatically determines the last page and prints it out (normal printing). That's it. I can't be more specific than this.
    Basically you open a document, run a macro and the last page of it prints instantly. Then you open another one and the same macro prints the last page of that document as well. You can assume that all documents are similar to the one posted in the other thread.

    And again, fumei posted

    3. print all pages up to the last two pages (1 to x-2)
    4. print last two pages (x + 1) - 2 to x + 1"


    Now, I would be happy to get only the last page print but if you can accomplish putting this in VBA, even better.

    P.S. To answer your questions:

    I am using Word 2003. (which has been stated in the very beginning of this thread)
    Printer is of no issue since a simple print job will do fine as long as there is an option to select the printer from the macro.
    I can't record something that does not exist within the MS Word. You can only select pages you want to print (specific or range) and a section of the document. You can also chose to print a selected text only. There is no option to print the last page only. There is an option called print last page first, but that's about it. I can't tell him / print the last page and the page that precedes it, or print the last page of the section 1 (without manually entering the number of the page) and the first page of the section 2.
    Recording of moving the cursor doesn't help either because the number of pages can vary, as I explained before.

    If you need any additional info I will be more than glad to provide it.
    Last edited by Zack; 04-30-2012 at 04:03 PM.

  15. #55
    Quote Originally Posted by Frosty
    [vba]
    Sub MagicMacro
    dim rngWhere as Range
    set rngWhere = ActiveDocument.Content
    rngWhere.Collapse wdCollapseEnd
    Application.Templates("C:\MyTemplate.dot").BuildingBlockEntries("MyEntry"). Insert where:=rngWhere, RichText:=True
    ActiveDocument.PrintOut
    End Sub
    [/vba]
    Run time error 5941

    Application.Templates

  16. #56
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Sigh.

    Zack, you are too certain of things that don't work. Don't be so certain. Just TRY the things which are asked of you. You will be surprised. It would be much more helpful if you said "I don't know HOW to record a macro to go to a specific page" -- because then we could answer "CTRL+G" will bring up the "GOTO" box (which is the third tab of the Find/Replace/Go To dialog. From there you will see that you can automatically go to a specific place in the document (including sections).

    Stop being so certain which things will work and which will not, please. It is not helping you and it is certainly not helping us help you.

  17. #57
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    And yes, the MagicMacro I posted will not work, because I suspect you do not have a template called "MyTemplate.dot" at the root of your C:\ drive, and I also suspect you do not have an Autotext entry called "MyEntry"

    In addition, since you are in Word 2003, that code wouldn't work even if you had that template and that autotext entry, because .BuildingBlockEntries only exist in Word 2007/2010.

    The task is not to run random bits of VBA posted on this board until something works.

    The task is to learn how to modify VBA so that it will work for you.

    Again, this forum is for helping you learn how to help yourself. It is not a forum for free VBA programming without any input from the original poster other than design specifications.

    In short, as has been said many times in this thread: you have to want to learn this stuff. If you don't want to learn this stuff, then you are wasting everyone's time, including your own.

  18. #58
    Quote Originally Posted by Frosty
    Sigh.

    Zack, you are too certain of things that don't work. Don't be so certain. Just TRY the things which are asked of you. You will be surprised. It would be much more helpful if you said "I don't know HOW to record a macro to go to a specific page" -- because then we could answer "CTRL+G" will bring up the "GOTO" box (which is the third tab of the Find/Replace/Go To dialog. From there you will see that you can automatically go to a specific place in the document (including sections).

    Stop being so certain which things will work and which will not, please. It is not helping you and it is certainly not helping us help you.
    Frosty, I am seriously starting to question my knowledge of English language. I thought that I was confused, but perhaps I was overcritical to myself..
    Imagine yourself asking for a help with a mouse software and all you get is an instruction of how to click the mouse properly. This is hilarious.

  19. #59
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    I just re-read the beginning of this thread. Your original problem, as best I can see, is the following:
    DocMain.doc has 10 pages.
    DocInsert.doc has 1(?) page.

    You want a single macro which would turn the above state (2 separate documents) into a single printout with...
    DocMain pages 1-9 printed out single-sided
    DocMain page 10 and DocInsert Page 1 printed out duplex.

    In order to do a duplex print job, you need to (at the very least), have a two page document (right?). Because otherwise it doesn't matter whether you have duplex printing turned on or not.

    So for a 10 page document with page 1 of the other document inserted as page 11, and the desire to have page 10 and page 1 printed on the same sheet of paper, you would need to have those pages be perceived by the printers as having page 10 be an "odd" page and the new page 11 be an "even" page, yes?

    Consider a 10 page document printed entirely duplex.

    Pages 1 & 2 will be on the first piece of paper.
    Pages 3 & 4 will be on the second piece of paper, and so on...

    So in an regular duplex job, page 10 and page 11 would *not* be on the same piece of paper, right?

    But if you original document were 9 pages, and you just wanted the new page 10 to be duplex, that would be relatively easy.

    But a 10 page document which becomes an 11 page document, *really* needs to be a 12 page document, with a "blank" page 10, in order to get the duplex job correctly done.

    Does the above make sense?

  20. #60
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    Quote Originally Posted by Zack
    Frosty, I am seriously starting to question my knowledge of English language. I thought that I was confused, but perhaps I was overcritical to myself..
    Imagine yourself asking for a help with a mouse software and all you get is an instruction of how to click the mouse properly. This is hilarious.
    Well, imagine how difficult it is when someone calls to say "my computer isn't working" and you spend 20 minutes diagnosing all the different things to try, and THEN you discover that the computer is not plugged in.

Posting Permissions

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