Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print Margin Based on File Extension 2

Status
Not open for further replies.

Jhtexas

Technical User
Jan 4, 2005
59
US
I’m looking for a way to set the print margins to certain values based on the file extension of the file being opened. The settings also produce a “Fix or Ignore” message that also has to be dealt with. This is because it has some text outside of the print area.
I’d appreciate any suggestions.

Thanks,
Jim
 
What I’m opening is an ASCII text file that has a .prn file extension. I want to be able to perform an IF statement evaluation on the extension and then change the print margins if it is a .prn file. I just need help with the format of the IF statement to evaluate the file name extension. These files are opened printed and never saved in the word file format.

So in short, when opening a file that has a .prn extension it performs the margin change.

Thanks,
Jim

 
You'll need to add the macro to normal.dot in order for it to run when any document is opened.
Code:
Sub Auto_Open()
If (UCase(Right(ActiveDocument.Name, 3)) = "PRN") Then
    With ActiveDocument.PageSetup
        .TopMargin = InchesToPoints(0.5)
        .BottomMargin = InchesToPoints(1)
        .LeftMargin = InchesToPoints(1.25)
        .RightMargin = InchesToPoints(1.25)
    End With
End If
End Sub
 
I copied the macro in and saved it within the normal.dot template with the name auto_open.

When I open a .prn file it does not activate the macro. If I run the macro after I have a .prn file open it works perfectly.

Do you have any ideas on what I’m doing wrong?

Thanks for your help,
Jim
 
Consistency across Office apps does leave something to be desired on occasion ...

In Word, it is AutoOpen (no hyphen).

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Do you have any other Auto Opens in normal.dot? Other auto opens have cause me trouble in the past. If so then you should rename the macro and call it from your existing auto open.
 
Thanks, that was it. With the AutoOpen it works great.

Thanks again,
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top