PDA

View Full Version : Check to see if an autotext entry is present in the document



jammy Bodger
02-19-2007, 06:16 AM
Not sure how to go about this one?

I have a letter template with a user form for entering letter details into it. The form also has option buttons to leave the document without a logo (the default) or to inset a logo into the header. This works fine for printing on headed paper however, I want the ability to automatically send the document via e-mail to the recipient.

I want to be able to check that if a logo has been inserted before the document is sent to outlook and if the document has no logo then to add it. I can adapt the code to add the logo but not sure how to perform the check prior to it being attached to an e-mail for sending.

Any suggestions or help would be greatly appreciated. Thanks, James

fumei
02-19-2007, 10:37 AM
The body of your post appears to have nothing to do with your subject.

The Subject is checking if an autotext entry is present in a document. BTW, to me that does not mean the autotext entry was USED, just if an autotext entry is in the document.

The body of your post makes no mention of autotext.

The logic seems odd. You give the user the option to insert the logo, or not. Yet you also want to automatically send the document WITH the logo. That does not seem to match giving the user the choice. If you want to automatically send, AND it has to have the logo...then don't give the user the choice. Put the logo in.

As for checking, if the header is otherwise empty - that is, if the header is either empty OR it has the logo, then simply check to see if the header is empty.

If it is, put in the logo.

jammy Bodger
02-19-2007, 01:07 PM
Hi Gerry,

Having re-read my post, I can see where some confusion has arisen. I will explain what I?m trying to achieve in more detail.

When the letter template is opened there is no logo in the document header. Using, userform_initialize, the form presents you with an option of inserting a logo among other things. At this point the user decides whether to add a logo depending on what they want to do with the letter i.e. to print a copy on headed paper and mail it in an envelope. If the user decides that they want the document to have the logo so that it can be emailed then, the logo which is stored as an auto text entry within the template is added to the document via code.

The recipient address details are filled in automatically on the user form from information contained in Outlook contacts. So if there is an e-mail address for the recipient then this is added to the custom document properties, which makes it available to use if there is a requirement to email the letter at document creation or later on, as well as traditional mailing.

I intend to add a toolbar and attach a macro to the toolbar that will allow the user to automatically pre address an Outlook e-mail with various details contained within the letter.

The purpose of my post question was that I wanted to make sure that the auto text logo was present in the header before this e-mail was created, just in case the user had forgotten to add the logo and therefore avoiding sending a letter without any corporate identity on it.

As you pointed out the illogic of my post, it may be easier to write a sub procedure to delete the contents of the header as it only contains the logo. I could then continue with the code to add it back, therefore if no logo is present then I will be deleting nothing and adding one and if one is present then I will be deleting it and re-adding it. Seems a possible workaround?

Regards James

fumei
02-19-2007, 02:46 PM
Well yes.

There is still a logic failure though. You mention the user "forgetting" to put the logo in. I beg to differ. If I understand it correctly, the user is choosing to either:

A) print for mailing. In which case, no logo wanted, as it will be printed on headed paper.

B) email. In which case, a logo is required in the document.

The user is making a choice. I assume that this choice must be made before they can close the userform.

In which case, it is not that the user forgot. It is possibly a case of the user changing their mind.

I know this seems splitting hairs. It is not.

Can you do an analysis of requirements? Is there a preponderance of one, or the other? Email vs print? 50-50?

If it is NOT 50-50, then put the logo in (or out) as the case may be.

IMO though, I would put the logo IN. Why? Because it would be easier to trap the essential requirement. Which is? If the document is emailed then you absolutely require the logo in. This is not negotiable. It is required. Fine.

If the logo is out and they print, what are the consequences? Ooops. Put the logo in, and print again. No embarassment. Fix it, client never knows.

OK?

So. How to trap this? Trap it at the printing. The user goes to print...check for a logo. If there is a logo, take it out.

Otherwise, the default is the logo is IN. So if it is email, no problem, it IS in.

Print? Check for logo. Not print, but email...already there.

However, I will reiterate that technically this is not a forgetting. It is a possible correction. The user must make a choice on the userform. They choose mail, then sure remove the logo, as they are choosing to print.

The userform closes. They go "Doh!", I really want it to be emailed. WHAT were you going to do to fire the action anyway??? The userform is closed.

This is just a suggestion. Trap the print commands (FilePrint and FilePrintDefault), and:

1. check for the logo
2. make the user confirm the printer is using the correct paper - the one with the printed header.

#2 could be done via code if you have a dedicated tray with header logo paper.