[VBA] Onay Kutusuna Göre Word'e Yazı Yazdırma Sorunu
#1
Öncelikle herkese kolay gelsin arkadaşlar. Accesste vba koduyla word şablonuna yer imi yardımıyla veri göndermekteyim.Buraya kadar herhangi bir sıkıntı yok kod çalışmakta.
Kullandığım kod:
Visual Basic
  1. Private Sub Komut31_Click()
  2. On Error GoTo Hata
  3.  
  4. Dim objWord As Word.Application
  5.  
  6. Set objWord = CreateObject("Word.Application")
  7.  
  8. With objWord
  9.  
  10. .Visible = True
  11.  
  12.  
  13. .Documents.Add (Me.Application.CurrentProject.Path & "\izinbelgesi.dotx")
  14.  
  15.  
  16. .ActiveDocument.Bookmarks("sinifi").Select
  17. .Selection.Text = Me.ŞUBE
  18. .ActiveDocument.Bookmarks("numarasi").Select
  19. .Selection.Text = Me.Metin14
  20. .ActiveDocument.Bookmarks("cikistarihi").Select
  21. .Selection.Text = Me.Metin16
  22. .ActiveDocument.Bookmarks("cikissaati").Select
  23. .Selection.Text = Me.Metin26
  24. .ActiveDocument.Bookmarks("dönüstarihi").Select
  25. .Selection.Text = Me.Metin18
  26. .ActiveDocument.Bookmarks("dönüssaati").Select
  27. .Selection.Text = Me.Metin28
  28. .ActiveDocument.Bookmarks("gün").Select
  29. .Selection.Text = Me.Metin20
  30. .ActiveDocument.Bookmarks("adisoyadi").Select
  31. .Selection.Text = Me.AdıSoyadı
  32. .ActiveDocument.Bookmarks("adres").Select
  33. .Selection.Text = Me.Adres
  34. End With
  35.  
  36.  
  37.  
  38. ' objWord.ActiveDocument.PrintOut Background:=False
  39. ' objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
  40. ' objWord.Quit
  41. Set objWord = Nothing
  42. Exit Sub
  43.  
  44. Hata:
  45. If Err.Number = 94 Then
  46. objWord.Selection.Text = ""
  47. Resume Next
  48. End If
  49. Exit Sub
  50. End Sub


Ancak yapmak istediğim şey ; Eğer onaykutusu 31 işaretliyse adres yer imine adres alanını eğer işaretli değilse adres yer imine metinkutusu42 içerisinde yazan bilgiyi göndermek.Birkaç kod denedim ,forumları inceledim, bulduğum şeyleri denedim ama başaramadım.Bu konuda yardımlarınız bekliyorum üstatlar.Saygılar...



  Alıntı
Bu mesajı beğenenler:
#2
Visual Basic
  1. Dim objWord As Word.Application
  2.  
  3. Set objWord = CreateObject("Word.Application")
  4.  
  5. With objWord
  6.  
  7. .Visible = True
  8.  
  9.  
  10. .Documents.Add (Me.Application.CurrentProject.Path & "\izinbelgesi.dotx")
  11.  
  12.  
  13. .ActiveDocument.Bookmarks("sinifi").Select
  14. .Selection.Text = Me.ŞUBE
  15. .ActiveDocument.Bookmarks("numarasi").Select
  16. .Selection.Text = Me.Metin14
  17. .ActiveDocument.Bookmarks("cikistarihi").Select
  18. .Selection.Text = Me.Metin16
  19. .ActiveDocument.Bookmarks("cikissaati").Select
  20. .Selection.Text = Me.Metin26
  21. .ActiveDocument.Bookmarks("dönüstarihi").Select
  22. .Selection.Text = Me.Metin18
  23. .ActiveDocument.Bookmarks("dönüssaati").Select
  24. .Selection.Text = Me.Metin28
  25. .ActiveDocument.Bookmarks("gün").Select
  26. .Selection.Text = Me.Metin20
  27. .ActiveDocument.Bookmarks("adisoyadi").Select
  28. .Selection.Text = Me.AdıSoyadı
  29.  
  30. IF (Me.onaykutusu31) = True Then
  31. .ActiveDocument.Bookmarks("adres").Select
  32. .Selection.Text = Me.Adres
  33. Else
  34. .ActiveDocument.Bookmarks("adres").Select
  35. .Selection.Text = Me.metinkutusu41
  36. End If
  37. End With
  38.  
  39.  
  40.  
  41. ' objWord.ActiveDocument.PrintOut Background:=False
  42. ' objWord.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
  43. ' objWord.Quit
  44. Set objWord = Nothing
  45. Exit Sub
  46.  
  47. Hata:
  48. If Err.Number = 94 Then
  49. objWord.Selection.Text = ""
  50. Resume Next
  51. End If
  52. Exit Sub
  53. End Sub



Yukarıdaki gibi bir deneyin. Sanırım istediğiniz olur. Kolay gelsin.



  Alıntı
Bu mesajı beğenenler:
#3
Çok teşekkür ediyorum EminA hocam.Kod metinkutusu veya onaykutusu yazınca olmuyor zaten metin sayısını da yanlış vermişim.Sizin verdiğiniz kodu şu şekilde yapınca sorun çözülmüş oldu.
Visual Basic
  1. If (Me.Onay31) = True Then
  2. .ActiveDocument.Bookmarks("adres").Select
  3. .Selection.Text = Me.Adres
  4. Else
  5. .ActiveDocument.Bookmarks("adres").Select
  6. .Selection.Text = Me.Metin35
  7. End If
  8. End With



Benim kendi denediğim kod da şu şekildeydi hatamı görmüş oldum.

Visual Basic
  1. Private Sub Onay31_AfterUpdate()
  2. If Me.Onay31 = True Then
  3. ActiveDocument.Bookmarks("adres").Select
  4. .Selection.Text = Me.Adres
  5. Else
  6. .ActiveDocument.Bookmarks("adres").Select
  7. .Selection.Text = Me.Metin35
  8. End If
  9. End With
  10. End Sub





  Alıntı
Bu mesajı beğenenler:


Benzer Konular...
Konu: Yazar Cevaplar: Gösterim: Son Mesaj
  [FORM] Onay Kutususun şarta Bağlı Olarak Otomatik Olarak Işaretlenmesi Samih KARSLI 2 81 06-04-2024, 18:49
Son Mesaj: Samih KARSLI
  Acceste Liste Kutusundan Seçilen Veriyi Metin Kutusuna Gönderme Pasham 24 294 04-04-2024, 01:18
Son Mesaj: halily
  [FORM] Aktif Saati Tablodaki Saat Arasına Göre Bulup Forma Yazdırma yahyamacit 5 136 14-03-2024, 11:07
Son Mesaj: yahyamacit
  [FORM] Inputbox Kutusuna Girilen Değere Pasword Maske Uygulama orderyazbim 2 141 22-01-2024, 22:12
Son Mesaj: orderyazbim
  [VBA] Dosya Yolu Yazdırma benuva 2 115 26-11-2023, 19:06
Son Mesaj: benuva
  [SORGU] Onay Kutusuna Göre Sorgu Listesi Oluşturma 88888888 6 373 31-07-2023, 16:40
Son Mesaj: 88888888
  [TABLO] Tablodaki Aynı Isimlerin Sayısını Yazdırma omergenc7 13 557 26-03-2023, 13:11
Son Mesaj: dsezgin
  Raporda şablona Yazdırma ankaram 6 229 30-01-2023, 10:53
Son Mesaj: alperalper

Foruma Git:


Bu konuyu görüntüleyen kullanıcı(lar): 1 Ziyaretçi