• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Soru Word belgesinin üst kısmında hk.

1903emre34@gmail.com

Altın Üye
Katılım
29 Mayıs 2016
Mesajlar
944
Excel Vers. ve Dili
Microsoft Excel 2013 Türkçe
Merhaba,

Commadn Button bastğım zaman "u.Rows(2).Cells(9).Range.Text = ComboBox5.Text" satır hata vemektedir, nedeni Belge word belgesinin üst kısmında yer alan "e" eklendiği için, hatayı nasıl giderebiliriz, istenen Belge1 word belgesinde yapılmıştır.
 
Merhaba

u.Rows(2).Cells(9) yazmışsınız fakat bu satırda 8 hücre var. Siz 9 yazdığınız için hata alıyorsunuz.

kontrolü şu şekilde sağlayabilirsiniz.

msgbox u.Rows(2).Cells.rows.count

sonuç 8 dönecektir.

Hata veren satır aşağıdaki gibi olmalı.

u.Rows(2).Cells(8).Range.Text = ComboBox5.Text
 
İlginiz için teşekkürler hata vermedi, üst kısmında bazı bilgiler gelmedi, istenen Belge1 yapılmıştır.
 
Kodun içindeki hata veren bölümü aşağıdaki gibi düzenleyip deneyin.

u.Rows(1).Cells(3).Range.Text = ComboBox1.Text & " A.Ş."
u.Rows(3).Cells(3).Range.Text = ComboBox3.Text
u.Rows(4).Cells(3).Range.Text = ComboBox6.Text
u.Rows(1).Cells(6).Range.Text = ComboBox2.Text
u.Rows(2).Cells(6).Range.Text = ComboBox4.Text
u.Rows(3).Cells(9).Range.Text = ComboBox5.Text
u.Rows(4).Cells(9).Range.Text = ComboBox7.Text
 
Hocam, oldu , ama word üst bilgi kısmında bazı üst kısmında bazı bilgiler gelmedi. (Bel word belgesinde sarı ile boyanmış hücreler)

Bel1 istenen word belgesi

Bel kodların uygulandığı sayfa
 
Word konusunda fazla bilgim yok ; bilgisi ve deneyimi olan üyelerimiz konuyla ilgilenirlerse cevap vereceklerdir.
İyi çalışmalar.
 
kod

PHP:
Private Sub CommandButton1_Click()
If Cells(Rows.Count, "C").End(3).Row < 4 Then Exit Sub
Dim s, y
Set s = CreateObject("Word.Application")
Set y = s.Documents.Open(ThisWorkbook.Path & "\Belge.doc")
    s.Visible = True
 y.PageSetup.DifferentFirstPageHeaderFooter = True
 Set u = y.Sections(1).Headers(2).Range.tables(1)
u.Rows(1).Cells(3).Range.Text = ComboBox1.Text & " A.Ş."
u.Rows(3).Cells(3).Range.Text = ComboBox3.Text
u.Rows(4).Cells(3).Range.Text = ComboBox6.Text
u.Rows(1).Cells(7).Range.Text = ComboBox2.Text
u.Rows(3).Cells(7).Range.Text = ComboBox4.Text
u.Rows(3).Cells(10).Range.Text = ComboBox5.Text
u.Rows(4).Cells(10).Range.Text = ComboBox7.Text
Range("C2:C" & Cells(Rows.Count, "C").End(3).Row).Copy
With y.Range
  .Paste
  Application.CutCopyMode = False
  .End = .tables(1).Range.End + 1
 .tables(1).ConvertToText 0
End With
 y.PageSetup.DifferentFirstPageHeaderFooter = True
Sayfa2.Shapes(Sayfa2.Cells(ComboBox8.ListIndex + 2, "I").Value).Copy
c = y.Sections(1).Footers.Count
For Each j In y.Sections(1).Footers
c = c - 1
j.Range.Paste
j.Range.Collapse wdCollapseEnd
j.Range.InsertAfter vbTab & vbTab & "Sayfa " & c & "/" & y.ActiveWindow.ActivePane.Pages.Count
Next
Application.CutCopyMode = False
Exit Sub
 If TextBox3 = "" Then ad = Date
  y.SaveAs Filename:=ThisWorkbook.Path & "\" & TextBox3 & ".doc"
 
  'g = MsgBox("işlem bitti,dosya kaydedildi kapatılsınmı?", vbYesNo)
  'If g = vbYes Then y.Close False
End Sub
 
Geri
Üst