Nerde hata yapıyorum acaba?
Kod:
Option Explicit
Dim Dosya As String
Sub word_sayfa_yapisi()
Dim s As Long
Dim DosyaSay As Long
DosyaSay = WorksheetFunction.CountA(Range("a2:a2000"))
For s = 1 To DosyaSay
Dosya = Range("A" & 1 + s).Value
SetupPage (Dosya)
Dosya = ""
Application.CutCopyMode = False
Next s
Range("A1").Select
Application.CutCopyMode = False
End Sub
Sub SetupPage(Dosya As String)
Dim AppWord As Word.Application
Set AppWord = CreateObject("Word.Application")
AppWord.Documents.Open Dosya
AppWord.Visible = True
With AppWord.ActiveDocument.PageSetup
.PageWidth = CentimetersToPoints(9)
.PageHeight = CentimetersToPoints(29.7)
.TopMargin = CentimetersToPoints(0.6)
.BottomMargin = CentimetersToPoints(0.6)
.LeftMargin = CentimetersToPoints(0.6)
.RightMargin = CentimetersToPoints(0.6)
End With
AppWord.ActiveDocument.Save
AppWord.ActiveDocument.Close
AppWord.Quit
Set AppWord = Nothing
End Sub