PDA

View Full Version : Printing macro - impossible?



Zack
04-20-2012, 01:53 PM
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!

macropod
04-21-2012, 02:10 AM
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.

Zack
04-21-2012, 07:59 AM
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.

macropod
04-21-2012, 02:57 PM
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.

Zack
04-21-2012, 11:41 PM
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?

macropod
04-22-2012, 04:48 AM
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.

Zack
04-22-2012, 06:00 AM
So it is impossible to write a working macro that would help my issue..

macropod
04-22-2012, 06:43 PM
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.

Zack
04-23-2012, 11:56 AM
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.

Frosty
04-23-2012, 12:36 PM
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.

macropod
04-23-2012, 03:26 PM
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.

Zack
04-23-2012, 10:18 PM
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?

Frosty
04-24-2012, 10:00 AM
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.

fumei
04-24-2012, 09:23 PM
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 understandThe 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.

Zack
04-25-2012, 11:39 AM
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.

macropod
04-25-2012, 02:44 PM
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.

Zack
04-25-2012, 10:17 PM
{INCLUDETEXT "C:\\documents\\document1.doc"}

Then I update with
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

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.

macropod
04-26-2012, 03:47 AM
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"}

Zack
04-26-2012, 08:41 AM
But how does it delete a header from that page alone? Not touching previous 40 pages with pre-defined header?

fumei
04-26-2012, 05:24 PM
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.

Zack
04-26-2012, 10:03 PM
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.

Well, if you number pages then you will have 50 pages and the next one will be 51'st. But if you want a standalone document to be printed as it's 51'st (and that document has one page) you don't want it to have a number 51 in header.

Evidence I've shown was clearly enough for macropod to give me the field code. What other evidence would you have me posted?

Pre-defined means when you define (your firm for example) how the header should look like for the each document printed.

You said I would need a VBA code. Is it so long and hard to write? This is VBA express forum after all.

fumei
04-26-2012, 10:47 PM
Post an example of what you have done with your first try using a field code. That would be evidence. Other than that, you are just posting words.

Well, if you number pages then you will have 50 pages and the next one will be 51'st. But if you want a standalone document to be printed as it's 51'st (and that document has one page) you don't want it to have a number 51 in header.Very true. What is also true is that - as I stated - you must make a new Section break.

What is also true is that you never mentioned anything about a change in header before.

Evidence I've shown was clearly enough for macropod to give me the field code. What other evidence would you have me posted?You gave no evidence. You gave a request, a question. And macropod gave you an effective answer to your question...which you have not tried to do. Or so it seems, as there is no eveidence - a posted sample document showing what you did for example - that you have done anything.

A header is a header, it is the contents of a header. It is what you put there. There is nothing pre-defined about it.

Here is what you need to do. While it is possible to have an INCLUDETEXT field in the first document, and ADD a Section break before it, the easiest route IMO is to use VBA to:
1. go to the end of the document
2. add a Section break
3. bring in the other document as an insert file.
.EndKey Unit:=wdStorywith
.InsertBreak Type:=wdSectionBreakNextPage
.InsertFile FileName:="Other.doc", Range:=""
end with
This will NOT - repeat NOT - change the header. In fact, the new Section will have the same header. I am not going to show you how to do that (change the header), because you did not ask for that.

fumei
04-26-2012, 11:19 PM
BTW: how is it going with your original issue, printing single then duplex? As stated by your need, I think you will need to do two separate print jobs.

macropod
04-27-2012, 02:37 AM
With all due respect, Gerry, all Zack really needs is to have is a 'Next Page' Section break between the IF field and the INCLUDETEXT field, with the document's new last Section's header & footer unlinked from those of the previous Section. No vba is needed for this - it's all basic document management. In any event (as you yourself observe), your code does nothing to address the header & footer issue.

Zack
04-27-2012, 09:37 AM
I am not going to show you how to do that (change the header), because you did not ask for that.

I thought I mentioned before that I needed to keep the header of the inserted document (blank), but perhaps I am wrong. You are right, you don't have to show it to me how it's done because I wasn't specific about what I need and even though there were some indications, those probably weren't precise enough, so I understand you completely.



Selection.InsertBreak Type:=wdSectionBreakNextPage
Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8", FileName _
:= _
"C:\documents\document1.doc" _
, LinkToFile:=True, DisplayAsIcon:=False

This is what very loosely gets the job done, though it does not scroll down the document to the last paragraph of it's last page automatically.

I tried your VBA code and it says: "Compile error. Invalid or unqualified reference".

Frosty
04-27-2012, 09:43 AM
Zack,

I think what you're kind of missing here is that you can attach actual documents to posts after you get 5 posts. It would probably be a good idea to post a dummy document, with your attempts to set it up the way it would work on your system... and then everyone would be looking at the same thing.

And while some settings wouldn't work (i.e., printer-specific settings like duplex), you could still have multiple people looking at the document you are attempting to print, with the field codes in it, and then describe what isn't working.

Other than that, it's all (as you said earlier) a little too conceptual and esoteric. Otherwise, I think you may need to hire someone.

VBA solutions (despite this being a VBA forum) are not always (and often not) the best solution. VBA solutions are typically (in my experience) thought to be "best" when the person requesting that solution doesn't understand all of the built-in capabilities of Word. In short, training often substitutes better than a one-off coding solution.

Can you try to dummy up a document and post it? That will probably get you closer to your desired solution than a lot more posts back and forth.

fumei
04-27-2012, 10:22 AM
I tried your VBA code and it says: "Compile error. Invalid or unqualified reference".True. I missed the opening With.
With Selection
.EndKey Unit:=wdStorywith
.InsertBreak Type:=wdSectionBreakNextPage
.InsertFile FileName:="Other.doc", Range:=""
End With The .EndKey instruction moves the document down to the end, which is where you want the Section break.

Paul,

With all due respect, Gerry, all Zack really needs is to have is a 'Next Page' Section break between the IF field and the INCLUDETEXT fieldYes, which is what I have been saying. He needs a Section break. And it has to be either:

a) before the INCLUDETEXT field is put in; OR
b) before the file is inserted.

If the operation is a one-off print job, then inserting the file, printing, then close without a save will do it.

If the operation is to be a permanent change (keeping the other document included), then using an INCLUDETEXT is the way to go.

fumei
04-27-2012, 10:23 AM
BTW: Why are you using an OLE object?????Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8", FileName _
:= _
"C:\documents\document1.doc" _
, LinkToFile:=True, DisplayAsIcon:=False

Zack
04-27-2012, 10:43 AM
VBA solutions are typically (in my experience) thought to be "best" when the person requesting that solution doesn't understand all of the built-in capabilities of Word. In short, training often substitutes better than a one-off coding solution.


I admit, I do not comprehend all of the Word's built in features, thus my question posted here in this forum. I sought for a solution that would resolve the problem at hand and found myself here asking for an advice from people more knowledgeable than myself. If nothing, than in the field of the MS Word/VBA. I am thankful for the training I received so far and I verily learnt a lot already. Henceforth I will try to find a way to automatically get to the last paragraph of the document's last page. This should greatly aid me in my efforts of finding the solution for the complete code that I require.

Zack
04-27-2012, 10:52 AM
True. I missed the opening With.
With Selection
.EndKey Unit:=wdStorywith
.InsertBreak Type:=wdSectionBreakNextPage
.InsertFile FileName:="Other.doc", Range:=""
End With

Run-time error '4120'

Debug "yellows" .EndKey Unit:=wdStorywith

Zack
04-27-2012, 10:57 AM
BTW: Why are you using an OLE object?????Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.8", FileName _
:= _
"C:\documents\document1.doc" _
, LinkToFile:=True, DisplayAsIcon:=False

My knowledge about VBA or Word 2003 is really limited. This is all I could find that could loosely accomplish what I had in mind, a part of it at least.

Frosty
04-27-2012, 12:43 PM
Zack, you should try recording macros that do what you want to do... even though that won't often be the "best" end product, it is a good Rosetta stone for initially learning VBA. That does, however, require understanding what you want to do and then doing it.

Even if someone posts code which doesn't work, but explains how it should work... you'll skip over some of the "typo" kinds of stuff.

the .EndKey Unit:=wdStory is what you're looking for... the "with" tag was a typo by Fumei.

On some of the simplest stuff, I would guess that some of us (myself included) often just type the code, rather than test it in VBA.

I still think you should work up a dummy document, with your attempt to use the fields indicated in the other posts, and then post that document (as well as the document you're trying to include), and then describe why that doesn't work.

Zack
04-27-2012, 01:11 PM
Zack, you should try recording macros that do what you want to do... even though that won't often be the "best" end product, it is a good Rosetta stone for initially learning VBA. That does, however, require understanding what you want to do and then doing it.

Even if someone posts code which doesn't work, but explains how it should work... you'll skip over some of the "typo" kinds of stuff.

the .EndKey Unit:=wdStory is what you're looking for... the "with" tag was a typo by Fumei.

On some of the simplest stuff, I would guess that some of us (myself included) often just type the code, rather than test it in VBA.


That's exactly how I got to the OLE object in the first place. I got it while recording a macro.

Thank you for correcting Fumei's code, it works good now.

fumei
04-27-2012, 02:46 PM
Not only a typo, but I did not look very well at what I posted (my bad).

Zack, I am curious about you tecording the macro that got you the OLE object. WHAT on earth did you do? Especially when I posted the InsertFile instruction. Did you not look at the code?

Oh. wait a second. Ok. OK. I see how you got there, but could you not see that it was significantly different from what I posted? It is still a little odd to do it that way though..

BTW: the stupid typo. I have this new laptop and it does the darndest things. It seems to jump the cursor around on its own. In a browser it closes, opens links apparently on its own. Hate it. I can be typing and all of the line. a sudden it jumps to start of

Like that.....(I kept that one)

Yes, record macros. Be VERY clear about what you want, and what you ask for.

Zack
04-27-2012, 10:40 PM
Not only a typo, but I did not look very well at what I posted (my bad).



Doesn't matter. As long as it works now. I should have seen it myself, but I still have difficulties with understanding the VBA, though I try.

Btw, I went to Insert - object - create from file and clicked "link to file".

Of course, your macro is a lot better because it automatically gets me down to the bottom of the document.

Now, is there a way to print that page (the inserted one) and the page before Only, with selecting a specific printer in the process such as
ActivePrinter = "Printer1" for example?

With Selection
.EndKey Unit:=wdStory
.InsertBreak Type:=wdSectionBreakNextPage
.InsertFile FileName:="Other.doc", Range:=""

ActivePrinter = "Printer1"

'then the rest

End With

Something that could be incorporated within this same macro. I can't tell him to print the pages 50-51, because the document can have 30, 40, 45 or 55 pages, it isn't always the same. I don't know how to tell him to print the inserted document (in my case 1 page only) together with the page that preceded it.

fumei
04-28-2012, 07:05 PM
1. Get the number of pages in the document (with the added included document)

2. print all the pages for that number - 1 using single printing

3. change the printer if needed; change to duplex

4. print the last two pages.

Basic logic really.

Zack
04-28-2012, 11:15 PM
1. Get the number of pages in the document (with the added included document)

2. print all the pages for that number - 1 using single printing

3. change the printer if needed; change to duplex

4. print the last two pages.

Basic logic really.

So there is no way that there is a command to print the inserted document, that we've discussed before, together with the page that preceded it, regardless of the overall number of the document's pages?

Something like:"If you run this macro, I will print the inserted document of macro together with the previous page." It is then something that could be used in all situations.

fumei
04-28-2012, 11:28 PM
So there is no way that there is a command to print the inserted document, that we've discussed before, together with the page that preceded it, regardless of the overall number of the document's pages?

Something like:"If you run this macro, I will print the inserted document of macro together with the previous page."

Huh? Of course there is. That is EXACTLY what I posted!

Print job #1 - print everyting up to the last two pages REGARDLESS of the number of pages (number of pages - 1).

Print job #2 - the inserted document, together with the page that preceded it, REGARDLESS of the overall number of pages

Please try to read posts carefully. Again, have you even tried anything yet?

You have been given a variety of possible ways to go. macropod's INCLUDETEXT and IF statements. Have you actually tried anything? My straight VBA, adding the Section break, insert file, and printing. Have you tried anything? There is still NO evidence you have done anything.

I think I am done here. It does not seem like you are paying attention.

Zack
04-29-2012, 01:38 AM
Huh? Of course there is. That is EXACTLY what I posted!



Yes you did. Now I will be able to print the last page and the page the precedes it regardless of how many pages the document has. I thought it was impossible to code something like that. Wonderful.


With Selection
.EndKey Unit:=wdStory
.InsertBreak Type:=wdSectionBreakNextPage
.InsertFile FileName:="Other.doc", Range:=""


End With

For the future reference, in case someone comes here seeking for the same thing, here's Fumei's code. It will automatically insert another file as the last page keeping it's original heading in the process, and then it will automatically print that page and the page before, regardless of the number of pages that the original document has. All of this in one macro, which means one click.

Big thanks to Fumei, macropod and all the rest who spent time in writing this code.

Frosty
04-29-2012, 12:08 PM
This post doesn't really help your cause, Zack.

Unless you think this entire forum is set up to make fun of people who know less about VBA than the experts who post answers, or the forum was set up to tease people by knowing an answer but not giving it, your sarcasm not only doesn't help, but you contribute to the problem by posting bad information.

The above code does not do what you say it does, obviously. It is also probably not even the best way to accomplish what you would want to do.

However, it is a sample of the kind of code which would be the result of recording a macro to get you closer.

What has been said repeatedly in this thread is two things:
1) the answer is not simple because it revolves around items which can only be tested in your specific environment

2) requests for you to post a document with samples of your progress, things you've tried, etc.

For example, if you had tried to record the macro of the process Fumei had described with his 4 steps of basic logic, and then posted that recording (after cleaning it up an trying to understand it), you would be closer to your goal.

These requests have been made not because people are lazy, but because you don't have the capacity to ask the right very specific conceptual programming questions, and thus seeing an actual document/recorded macro would help give concrete information your lack of knowledge prevents you from conveying.

But there's really no need to get sarcastic with people who are, ultimately, trying to help you

Frosty
04-29-2012, 12:13 PM
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.

Zack
04-29-2012, 12:57 PM
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.

Zack
04-29-2012, 01:19 PM
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.

fumei
04-29-2012, 04:17 PM
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.

Zack
04-29-2012, 10:17 PM
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.

Zack
04-30-2012, 07:53 AM
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.

Frosty
04-30-2012, 10:07 AM
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.

Zack
04-30-2012, 12:45 PM
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.

fumei
04-30-2012, 12:58 PM
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.

Frosty
04-30-2012, 01:04 PM
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

Zack
04-30-2012, 02:13 PM
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.

Zack
04-30-2012, 02:16 PM
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?

Frosty
04-30-2012, 02:35 PM
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...


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

Zack
04-30-2012, 03:50 PM
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.

Zack
04-30-2012, 04:07 PM
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


Run time error 5941

Application.Templates

Frosty
04-30-2012, 04:10 PM
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
04-30-2012, 04:14 PM
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.

Zack
04-30-2012, 04:26 PM
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.

Frosty
04-30-2012, 04:27 PM
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?

Frosty
04-30-2012, 04:29 PM
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.
:)

Zack
04-30-2012, 04:30 PM
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.



I created a template for this purpose, though, I did not have an autotext entry.

But why would you give me something that you know it wouldn't work for the Word 2003 since I already said I am using the Word 2003?

Frosty
04-30-2012, 04:34 PM
Zack,
I understand that language is a barrier. But you need to take the time to translate the entire post and try to understand it. Don't skip to whatever VBA code in the post, copy, paste, run it and then say "it doesn't work."

I posted that code as a demonstration of how short the VBA code *could* be. Not as a possible solution. And I didn't remember that you had 2003, or I would have posted code which substituted .BuildingBlockEntries with .AutotextEntries.

It still would not have worked, however.

Zack
04-30-2012, 04:38 PM
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.
:)

Well Frosty, it helps when you actually read what other people have to say, and I wouldn't emphasize it if I haven't already quoted myself on several occasions. I should probably consider using copy paste more often..

For example:"Hey guys, I am using Word 2003...etc."

Then comes the reply:"Here's the code, but of course it won't work for the Word 2003".

I remember a case where a doctor accidentally extracted the wrong kidney from his patient. He wasn't reading a diagnosis carefully. He realised it later though not that it helped his patient in any way.

Frosty
04-30-2012, 04:39 PM
Fundamentally, if you can't accomplish a task manually in Microsoft Word (however long it takes), then Microsoft Word VBA cannot provide the solution.

VBA simply speeds up the tasks you can already accomplish.

This is why so much of this thread has revolved around trying to find out what YOU can accomplish manually.

Consider a thread which says "Looking for Word VBA code to build a car engine."

That would be silly, right? Well, so is this whole thread-- if you cannot manually achieve duplex printing with the printer you currently have.

Zack
04-30-2012, 04:41 PM
Don't skip to whatever VBA code in the post, copy, paste, run it and then say "it doesn't work."

I posted that code as a demonstration of how short the VBA code *could* be. Not as a possible solution. And I didn't remember that you had 2003, or I would have posted code which substituted .BuildingBlockEntries with .AutotextEntries.



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.

This is my post in which you have all the necessary info and you haven't even looked at it.

Frosty
04-30-2012, 04:42 PM
I apologize for posting Word 2010 code in a thread where you've already specified you use Word 2003.

Let's skip to the part of the conversation where we get back to trying to solve your problem. Anecdotes and language barriers aside... the last real post was my description of how the duplex printing process works.

Does what I posted make sense?

Zack
04-30-2012, 04:48 PM
I apologize for posting Word 2010 code in a thread where you've already specified you use Word 2003.

Let's skip to the part of the conversation where we get back to trying to solve your problem. Anecdotes and language barriers aside... the last real post was my description of how the duplex printing process works.

Does what I posted make sense?

There is a proverb Medice cura te ipsum.

Below is my post and I would appreciate it if you would just take some time to read it, if nothing else.

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.

Zack
04-30-2012, 04:50 PM
First we have to make sure that you understand what I wrote before we can move along. If that's ok with you?

Frosty
04-30-2012, 04:56 PM
Zack,

You have two options here:
1) You can try to prove your point, or
2) you can try to get your problem solved.

I read your post, I understood it, and I have responded to it already.

That was my post about you being so certain which things are possible and which are not. My response was contained in the post about using CTRL+G in order to record a macro to go to a specific section or page.

Now, I'm going to quote myself, and would appreciate a response. If you cannot respond to that, but instead insist on a point I am uninterested in... you can do it on your own in this thread.

Last chance. Up to you. I harbor no ill-will, but I am becoming bored with trying to help you when you seem disinterested in being helped, and rather more interested in being right.


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?

Zack
04-30-2012, 05:04 PM
I read your post, I understood it, and I have responded to it already.



I understand that my questions can be too difficult and that the answers would be more time consuming than a person can afford it so I've decided for the very least I can possibly ask help for.

A way for a VBA to automatically recognize and print the last page of any document.
Nevermind sections, duplex etc. This is it. Nothing else.

Frosty
04-30-2012, 05:07 PM
Then I will end my participation in this thread with a quote of my own "you cannot help those who do not wish to be helped."

Good luck!

Zack
04-30-2012, 05:17 PM
Then I will end my participation in this thread with a quote of my own "you cannot help those who do not wish to be helped."

Good luck!

I am sorry you feel that way. I really tried my best in describing my problem and the things I need some help with. I am certain you are a very good VBA programmer and that it was solely my lack of proper terminology in posts that confused you. Still, I am thankful for your time and furthermore, for the things that you taught me about Word 2003 and VBA.

All the best!

Frosty
04-30-2012, 05:21 PM
Zack,

You are always welcome to come back when you are less upset and respond to the quoted text in post #69 and re-open your question. I believe the other thread addresses your more simple problem of simply printing the last page of a particular section.

With the new information about using the Go To box, you can also try recording macros to navigate to a specific page and a specific section, and then use the PrintCurrentPage option.

There are many ways to address this problem, but you do have to be an active participant interested in continuing to learn. I'm not satisfied with this resolution either, but until we can come to a mutual understanding about your required level of understanding and participation in order to achieve a solution which works for you, we are simply banging heads against the wall in our own individual ways.

All the best to you as well!

- Jason/Frosty

Zack
04-30-2012, 05:59 PM
Frosty,

henceforth I will try my best to be an active participant in this forum to learn more about VBA in order to help resolving mine, as well as perhaps issues of others in the future. Pretentious as it may sound, but I truly want to help others as you and the rest have tried to help me.

Go To box, and recording the macro of it, would do wonders for the documents which would always have the same number of pages and sections. Problem comes when you can't anticipate the exact number of pages for the future documents. However, it is a valuable tool which will already find it's purpose.

I am satisfied with the resolution of this issue, because I've learnt a lot more than you think. Of course, without your assistance in guiding me I would probably be still walking in the dark, trying to see a simple difference between BuildingBlock and AutoText. Being erudite truly stands for educated individuals who willingly share their abundant knowledge with others who are more than happy to receive some valuable information.

Best of luck to you in your future endeavours.

Zack

Frosty
04-30-2012, 06:06 PM
Zack,

The combination of recording macros (to see how to do stuff, i.e., the Go To box) with writing functions to determine values (i.e., the functions in the other thread to determine specific page numbers of a specific section) is why the Go To box is useful, even in documents you don't already know the number of pages. Obviously recording a macro to "go to page 5" is not useful in a 4 page document.

But being able to understand the macro which "goes to page 5" combined with learning how to, for example, see what page the 3rd table of the document is on can easily be combined into a macro which "automatically prints the page the 3rd table of the document is in."

This kind of learning is the building block for learning everything you want to know. It is the approach on "how to learn" which is more important than any single answer.

Hopefully that is something you've taken out of this thread.

And for the rest... if you come back to this thread, I think you will see that all the components in this thread and the other are actually there for you to be able to solve your original problem. But it is your problem to solve. We will continue to be here to help you solve your problems, but we can't solve them for you.

Looking forward to your participation.

Frosty
04-30-2012, 06:09 PM
In short, recording macros can serve one or both of the following purposes:
1) to automate repetitive processes
2) to provide a launching point for a more advanced macro.

Don't think recording macros is only for #1. They are also a great tool for simply learning (even if the actual recorded macro is not useful for doing anything).

fumei
04-30-2012, 06:12 PM
{quote]
I understand that my questions can be too difficult and that the answers would be more time consuming than a person can afford it so I've decided for the very least I can possibly ask help for.

A way for a VBA to automatically recognize and print the last page of any document.
Nevermind sections, duplex etc. This is it. Nothing else.[/quote]Now you are getting insulting. Your questions are not too difficult.

Yes, there is a way for VBA to print the last page of any document. No duplex, no anything...just the last page. NOT the last page of a section, but the last page of the document - which is what you ask.

I have posted thousands of lines of code on this site, for hundreds of people, and hundreds of questions (most much more complicated than this stuff), for free. I will not post this for you.

The code has already been posted here...if you paid enough attention to read 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.
True. HOWEVER, you have been shown how to get those page numbers. You CAN get the page number of the last page of Section 1, AND the page after it.

Once you have those numbers...print the darn things.

Zack
04-30-2012, 06:14 PM
Obviously recording a macro to "go to page 5" is not useful in a 4 page document.


I believe that the language barrier has already begun to disperse.

I will read the entire thread again in case I've missed something important, because it seems that I've yearned too much for the solution without paying enough attention to the process of getting to it.

Thank you for bringing this up to my attention.

Frosty
04-30-2012, 07:06 PM
I think re-reading the thread is a great idea, Zack. There is a lot of good info in this thread (I learned stuff too, which is one of the reasons why I do this).

I think Paul's original suggestion of field codes to get you a blank page in certain circumstances is actually a great idea in terms of getting your duplex print job to work. I could see a macro which

1. Prints all the pages of Section 1, except for the last page
2. Inserts the field codes necessary to give a blank page (or not) in order to get the duplex print job correct
3. Prints the last page of the section and the newly inserted text from another document as a duplex print job.

But it would take some testing in your environment as well as a decent understanding of how to put the various pieces together in your environment. I don't actually have a duplex printer I could test this on, but I think you're on your way now to at least finding the various pieces and trying. And that's the most important thing.

Good luck!