(17/12/2022, 22:13)berduş yazdı: Kodu aşağıdaki gibi düzenleyip dener misiniz?
Deneme imkanım olmadı teorik
Option Explicit
Dim Dosya As String
Sub word_sayfa_yapisi()
Dim s As Long
Dim DosyaSay As Long
DosyaSay = WorksheetFunction.CountA(Range("a2:a2000"))
Set tmpAppWord = CreateObject("Word.Application")
For s = 1 To DosyaSay
Dosya = Range("A" & 1 + s).Value
SetupPage (Dosya, tmpAppWord)
Dosya = ""
Application.CutCopyMode = False
Next s
TmpAppWord.Quit
Set tmpAppWord = Nothing
Range("A1").Select
Application.CutCopyMode = False
End Sub
Sub SetupPage(Dosya As String, AppWord as object)
'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
End Sub
Öncelikle ilginize teşekkür ederim. Vba kod sayfasında "Compile error: Variable not defined" mesajı verip "tmpAppWord =" metninin üzerini işaretliyor.