Keybd Event Question - AGAIN!

So, I’m having problems with a script to change the margins to .15 in a document in the Post Open event.

Here’s the code:

keybd_event 46,0,0,0 ' . key down

keybd_event 46,0,2,0 ' . key up

keybd_event Asc("1"),0,0,0 ' 1 key down

keybd_event Asc("1"),0,2,0 ' 1 key up

keybd_event Asc("5"),0,0,0 ' 5 key down

keybd_event Asc("5"),0,2,0 ' 5 key up

and I tried:

keybd_event Asc("."),0,0,0 ' . key down

keybd_event Asc("."),0,2,0 ' . key up

keybd_event Asc("1"),0,0,0 ' 1 key down

keybd_event Asc("1"),0,2,0 ' 1 key up

keybd_event Asc("5"),0,0,0 ' 5 key down

keybd_event Asc("5"),0,2,0 ' 5 key up

But it always sets the margin at 11.69.

It works fine if I set the margin to a whole number - like 0 or 1 but it has a hard time with the decimals.

Any ideas?

Subject: RE: Keybd Event Question - AGAIN!!!

Perhaps it would be easier to prepare an alternate form that you use for printing. The SwitchForm @Command can be used in edit mode (or you can use DialogBox), which is handy if someone without access to edit the document wants to print it, plus it works cross-platform. You can adjust the indentation of the rich text by putting the field in a table that has an empty first column of fixed width, for instance.

Subject: RE: Keybd Event Question - AGAIN!!!

that doesn’t do anything to solve my issue.

I’m doing this to make sure that the margins are set properly on a form before printing it. It gets printed on a pre-filled out form and the margins have to be at .15 inch for everything to line up properly.

These forms are kind of expensive and we keep having to void them due to people forgetting to set their margins.

Subject: RE: Keybd Event Question - AGAIN!!!

Ah. You don’t want to adjust every document, just the ones that haven’t been done “right.”

Then instead of setting the margin, why don’t you use DXL to check the rich text in the document and just test the margin? If it’s too small, ask the user to fix it, and refuse to print.

Bear in mind that if they’re editing rich text, it may well be legitimate for them to have some lines indented more than .15", e.g. a bullet list within the text. Making everything the same indentation would mess them up.

But why do you put your users to the extra work of setting the margins manually, instead of putting the rich text field in a table or layer to begin with, so that it’s automatically indented the right amount on all forms from now on? You’re making the users serve the application; it should be the other way around, as much as you can manage it.

You might then run a DXL agent to correct all your old docs to zero indentation, in case someone needs to reprint them.

Or, use a special form for printing, as I’ve described, and tell the users to not bother to set the margins. It’ll look different on their screen than on the form, but so what?

Subject: RE: Keybd Event Question - AGAIN!!!

I got it figured out.

The script automatically selects the printer and prints. when it does, I have it adjust the margins too.

I just needed to know what the ascii code for a . decimal was. The left and right margins are all set to 0, but if they are printing something else they might adjust the margins so it’s just easier to have it set it for them.

it works like a champ using the keybd event stuff. it even makes sure it’s in portrait and not landscape and selects the correct printer for them.

I’m having no more issues with this.

but I appreciate your response.