Hope you can help me.
I created this very simple Word 2007 recorded macro for fixing the page margins and font in a .txt file created in diferent old program.
Worked for a long time without any problems.
Suddenly now, when I ran the macro I am getting this 5097 run-time error.
Debag getts me to this line :
With ActiveDocument.Styles(wdStyleNormal).Font
If I record another one, I have the same problem.
Thanks for your help!
__________________________________________________________
The code:
Sub CP_sreduvanje_snimanje_prakanje_printanje()
'
' CP_sreduvanje_snimanje_prakanje_printanje Macro
'
'
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
Selection.Font.Name = "Courier New"
Selection.Font.Size = 7
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(5#)
.BottomMargin = CentimetersToPoints(4.3)
.LeftMargin = CentimetersToPoints(0.5)
.RightMargin = CentimetersToPoints(0.5)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.25)
.FooterDistance = CentimetersToPoints(1.25)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.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
ActiveDocument.Save
End Sub
I created this very simple Word 2007 recorded macro for fixing the page margins and font in a .txt file created in diferent old program.
Worked for a long time without any problems.
Suddenly now, when I ran the macro I am getting this 5097 run-time error.
Debag getts me to this line :
With ActiveDocument.Styles(wdStyleNormal).Font
If I record another one, I have the same problem.
Thanks for your help!
__________________________________________________________
The code:
Sub CP_sreduvanje_snimanje_prakanje_printanje()
'
' CP_sreduvanje_snimanje_prakanje_printanje Macro
'
'
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.WholeStory
Selection.Font.Name = "Courier New"
Selection.Font.Size = 7
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(5#)
.BottomMargin = CentimetersToPoints(4.3)
.LeftMargin = CentimetersToPoints(0.5)
.RightMargin = CentimetersToPoints(0.5)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.25)
.FooterDistance = CentimetersToPoints(1.25)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.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
ActiveDocument.Save
End Sub