#1
|
|||
|
|||
non-DOC default format
I am involved in a project to update old applications which make liberal use of batch files, many of which open text files with Word2003 e.g. .TXT, .LOG etc. These files do not open with the same template as the default Office template or the user-modified template, nor any of the other defined templates. Searching the forum and the web about the format Word uses to open non-DOC files has been unsuccessful. LOG files can have very long lines, and are more readable when the formatting is with slim margins, a smaller font size, and Landscape orientation. Does anyone know if there is a way to modify the format that Word uses when opening non-DOC files? Thanks |
#2
|
||||
|
||||
In a word, no. You can, of course, change the page layout once the documents are open.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
non-DOC default format
Quote:
Much appreciated, not the answer I wanted of course... |
#4
|
||||
|
||||
Why not include an autoopen macro in Normal's Document Module or an addin that checks to see the file extension and changes the page setup if it hits one of the triggers?
Code:
Sub Document_Open() On Error GoTo FailWithGrace Select Case Split(lcase(ActiveDocument.Name), ".")(1) Case "txt", "log" With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientLandscape .TopMargin = CentimetersToPoints(1) .BottomMargin = CentimetersToPoints(1) .LeftMargin = CentimetersToPoints(1) .RightMargin = CentimetersToPoints(1) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1) .FooterDistance = CentimetersToPoints(1) .PageWidth = CentimetersToPoints(29.7) .PageHeight = CentimetersToPoints(21) .FirstPageTray = wdPrinterDefaultBin .OtherPagesTray = wdPrinterDefaultBin .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With End Select FailWithGrace: End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
non-DOC default format
Thank you
You are taking me into a new realm of functionality, very much appreciated. |
#6
|
||||
|
||||
Somewhat simpler and, perhaps, more effective:
Code:
Sub Document_Open() Application.ScreenUpdating = False Dim i As Long With ActiveDocument Select Case Split(LCase(.Name), ".")(1) Case "txt", "log" For i = 1 To Application.Templates.Count If Application.Templates(i).Name = "Normal.dotm" Then .AttachedTemplate = Application.Templates(i) Exit For End If Next .PageSetup.PaperSize = .AttachedTemplate.PageSetup.PaperSize .PageSetup.Orientation = wdOrientLandscape .PageSetup.TopMargin = CentimetersToPoints(0.6) .PageSetup.BottomMargin = CentimetersToPoints(0.6) .PageSetup.LeftMargin = CentimetersToPoints(0.6) .PageSetup.RightMargin = CentimetersToPoints(0.6) .Range.Font.Size = 10 End Select End With Application.ScreenUpdating = True End Sub For Mac macro installation & usage instructions, see: Word:mac - Install a Macro
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
||||
|
||||
Paul
I'm not sure how those modifications achieve the OPs stated aims. Why would you need the loop to verify Normal.dotm is an active template before attaching it? Is it possible to have Word (2007 or later) open without Normal.dotm also active? I would assume anytime you open a plain text file in Word, by default it has Normal.dotm attached anyway - could it conceivably be anything else? Then why do you want to import Normal's margins when the user wanted a small margin layout and didn't say they wanted the same margins as Normal.dotm. This misses the 'landscape' requirement too. We have both ignored the 'smaller font' requirement which might call for a template attachment and refreshing styles. It appeared in my testing that the text had the Plain Text style applied so maybe it is as simple as changing that style.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#8
|
||||
|
||||
Somewhere behind the scenes, Word uses a built-in specification for the page layout of plain text files, not those specified in Normal.dotm.
As the OP observed: Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
non-DOC default format
An update on how Paul's assistance led me to a functional macro
Rather than restricting to .txt and .log changed the code for a macro I could apply to any file. Code:
Sub LandscapeLST9() ' ' LandscapeLST9 Macro ' Application.ScreenUpdating = False Dim i As Long With ActiveDocument .PageSetup.Orientation = wdOrientLandscape .PageSetup.TopMargin = CentimetersToPoints(0.6) .PageSetup.BottomMargin = CentimetersToPoints(0.6) .PageSetup.LeftMargin = CentimetersToPoints(0.6) .PageSetup.RightMargin = CentimetersToPoints(0.6) End With With Selection.Font .Name = "Lucida Sans Typewriter" .Size = 9 End With Application.ScreenUpdating = True End Sub Many thanks Paul |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Default date format | gebobs | Excel | 0 | 03-03-2015 10:16 AM |
How can I set *.doc as default save format and NOT *.docx? | pstein | Word | 1 | 01-11-2012 09:30 AM |
Format Picture... Is there a Style-like default? | Bobosmite | Word | 0 | 07-19-2010 06:26 PM |
How to set Message Format default | TonyBender | Outlook | 0 | 10-27-2009 11:52 AM |
Default Number Format | boutells | Excel | 1 | 05-20-2009 02:46 PM |