Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-20-2020, 12:54 PM
melburn melburn is offline non-DOC default format Windows 7 32bit non-DOC default format Office 97-2003
Novice
non-DOC default format
 
Join Date: Jul 2019
Posts: 6
melburn is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 05-20-2020, 03:59 PM
macropod's Avatar
macropod macropod is offline non-DOC default format Windows 7 64bit non-DOC default format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In a word, no. You can, of course, change the page layout once the documents are open.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-25-2020, 03:15 PM
melburn melburn is offline non-DOC default format Windows 7 32bit non-DOC default format Office 97-2003
Novice
non-DOC default format
 
Join Date: Jul 2019
Posts: 6
melburn is on a distinguished road
Default non-DOC default format

Quote:
Originally Posted by macropod View Post
In a word, no. You can, of course, change the page layout once the documents are open.

Much appreciated, not the answer I wanted of course...
Reply With Quote
  #4  
Old 05-29-2020, 11:52 PM
Guessed's Avatar
Guessed Guessed is offline non-DOC default format Windows 10 non-DOC default format Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #5  
Old 05-30-2020, 12:22 AM
melburn melburn is offline non-DOC default format Windows 7 32bit non-DOC default format Office 97-2003
Novice
non-DOC default format
 
Join Date: Jul 2019
Posts: 6
melburn is on a distinguished road
Default non-DOC default format

Thank you



You are taking me into a new realm of functionality, very much appreciated.
Reply With Quote
  #6  
Old 05-31-2020, 05:26 PM
macropod's Avatar
macropod macropod is offline non-DOC default format Windows 7 64bit non-DOC default format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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 PC macro installation & usage instructions, see: Installing Macros
For Mac macro installation & usage instructions, see: Word:mac - Install a Macro
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 06-01-2020, 06:15 PM
Guessed's Avatar
Guessed Guessed is offline non-DOC default format Windows 10 non-DOC default format Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #8  
Old 06-01-2020, 07:56 PM
macropod's Avatar
macropod macropod is offline non-DOC default format Windows 7 64bit non-DOC default format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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:
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.
My code simply ensures Normal.dotm is attached, then applies that template's page layout. I missed the bit about margins, orientation and font size, which I've now rectified.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 07-14-2020, 03:44 PM
melburn melburn is offline non-DOC default format Windows 7 32bit non-DOC default format Office 97-2003
Novice
non-DOC default format
 
Join Date: Jul 2019
Posts: 6
melburn is on a distinguished road
Default 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
Reply With Quote
Reply

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
non-DOC default format 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
non-DOC default format Default Number Format boutells Excel 1 05-20-2009 02:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft