[VBA] Word Şablona VB Kodları ile veri işletmede faydalı olabilecek notlar
#1
Arkadaşlar word şablona gönderme Vb / makro kodları kullanarak gönderme faydası olabileceğini düşündüğüm derlediğim bazı notlar
Faydası olması dileğimle



-------- Tek Satır Silmek ----------------
Selection.Delete Unit:=wdCharacter, Count:=1
‘ -------- 3 Satır işaretleyip Silmek ----------------
Selection.MoveDown Unit:=wdLine, Count:=3, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
‘ -------- Paragraf ekleyip kelime eklemek ----------------
Selection.TypeParagraph
Selection.TypeText Text:="Eklenecek Metin"
‘ -------- 5 Paragraf işaretleyip Kesmek ----------------
Selection.MoveDown Unit:=wdLine, Count:=5, Extend:=wdExtend
Selection.Cut
‘--------- Yer İmi Ekleme --------------
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Satır1"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.TypeParagraph
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="Satır2"
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
‘------------ Yer İmi Silme
ActiveDocument.Bookmarks("Satır2").Delete
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
‘------------- Yer İmine Gitmek ----------------
Selection.GoTo What:=wdGoToBookmark, Name:="Satır2"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
‘------- Cümlenin başı sonu kelime ekleme
Selection.HomeKey Unit:=wdLine
Selection.TypeText Text:="Başa Git "
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:=" Sona Git"
‘-------Cümlenin Başından sonuna işaretleme Kalın ve alt çizgili yap
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Bold = wdToggle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineSingle
‘-------Cümlenin Başından sonuna işaretleme Kalın ve alt çizgi kaldırma
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Bold = wdToggle
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.MoveRight Unit:=wdCharacter, Count:=1
‘------------- Seçimi kalın ve alt çizgili yapar ve iptal eder
Selection.Font.Bold = wdToggle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineSingle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineNone
Selection.Font.Bold = wdToggle
‘-----------Mosue ile Seçimi kalın ve alt çizgili yapar ve iptal eder
Selection.Font.Bold = wdToggle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineSingle
Selection.Font.Bold = wdToggle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineNone
‘-------------------- İşaretleyerek seçim
Selection.MoveRight Unit:=wdCharacter, Count:=28, Extend:=wdExtend
Selection.Font.Bold = wdToggle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineSingle
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Font.Bold = wdToggle
Selection.Font.UnderlineColor = wdColorAutomatic
Selection.Font.Underline = wdUnderlineNone
‘-----------Seçilen yere Hafızadakini yapıştırma
Selection.PasteAndFormat (wdFormatOriginalFormatting)
‘-----------Seçilen yere Yazı yazdırma
Selection.TypeText Text:="Eklenecek Metin"
‘------- yazıyı Ayarları ----------------
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter ‘------ Yazıyı ortala
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft ‘------ Sola Yasla
Selection.ParagraphFormat.Alignment = wdAlignParagraphRight‘------ Sağa Yasla
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify ‘------- 2 yana yasla
‘----------------Metnin başına tab ekleme
Selection.TypeText Text:=vbTab
‘------------------ İlk Karakteri seçip silme
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
‘------------------ İlk 3 karakteri seçip silme
Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
‘-------- İlk Üç Cümleyi seç Kalın ve altı çizgili yap ------
Selection.MoveRight Unit:=wdWord, Count:=3, Extend:=wdExtend
Selection.Font.Bold = wdToggle
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.
Underline = wdUnderlineNone
End If
‘-------- İlk Üç Cümlenin sonuna 2 tab ve 2 nokta üstüste ekle sonra seç Kalın ve altı çizgili yap sonra kalın ve altı çizgiyi iptal et ------
Selection.MoveRight Unit:=wdWord, Count:=3
Selection.TypeText Text:=vbTab & vbTab & ":" ’sonuna tab ve : ekle
Selection.MoveLeft Unit:=wdCharacter, Count:=38, Extend:=wdExtend
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.Font.Bold = wdToggle
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Font.Bold = wdToggle
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
‘-------- Cümlenin sonun git kelime ekle------
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:="Eklenecek Metin"
‘-------- Cümlenin sonun git Kalın ve altı çizgiyi iptal et kelime ekle------
Selection.EndKey Unit:=wdLine
Selection.Font.Bold = wdToggle
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:="Eklenecek Metin"
‘-------- Sayfa Kenar Ayarlarını (Çetveli Ayarlama ------
Selection.PageSetup.LeftMargin = CentimetersToPoints(2.25)
Selection.PageSetup.LeftMargin = CentimetersToPoints(2)
Selection.PageSetup.LeftMargin = CentimetersToPoints(1.75)
Selection.PageSetup.LeftMargin = CentimetersToPoints(1.5)
Selection.PageSetup.LeftMargin = CentimetersToPoints(1.25)
Selection.PageSetup.LeftMargin = CentimetersToPoints(1)
Selection.PageSetup.LeftMargin = CentimetersToPoints(1)
Selection.PageSetup.RightMargin = CentimetersToPoints(2.5)
Selection.PageSetup.RightMargin = CentimetersToPoints(2.25)
Selection.PageSetup.RightMargin = CentimetersToPoints(2)
Selection.PageSetup.RightMargin = CentimetersToPoints(1.75)
Selection.PageSetup.RightMargin = CentimetersToPoints(1.5)
Selection.PageSetup.RightMargin = CentimetersToPoints(1.25)
Selection.PageSetup.RightMargin = CentimetersToPoints(1)
Selection.PageSetup.RightMargin = CentimetersToPoints(0.75)
Selection.PageSetup.RightMargin = CentimetersToPoints(0.75)
Selection.PageSetup.TopMargin = CentimetersToPoints(2.25)
Selection.PageSetup.TopMargin = CentimetersToPoints(2)
Selection.PageSetup.TopMargin = CentimetersToPoints(2)
Selection.PageSetup.TopMargin = CentimetersToPoints(1.75)
Selection.PageSetup.TopMargin = CentimetersToPoints(1.5)
Selection.PageSetup.TopMargin = CentimetersToPoints(1.5)
ActiveWindow.ActivePane.VerticalPercentScrolled = -167
Selection.PageSetup.BottomMargin = CentimetersToPoints(2.25)
Selection.PageSetup.BottomMargin = CentimetersToPoints(2)
Selection.PageSetup.BottomMargin = CentimetersToPoints(2)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1.75)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1.5)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1.25)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1.5)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1.25)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1)
Selection.PageSetup.BottomMargin = CentimetersToPoints(1)
‘-------- 1.5 inç Sayfa Kenar Çizgisi Ekleme ------
With Selection.Sections(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth150pt
.Color = wdColorAutomatic
End With
With .Borders
.DistanceFrom = wdBorderDistanceFromPageEdge
.AlwaysInFront = True
.SurroundHeader = True
.SurroundFooter = True
.JoinBorders = False
.DistanceFromTop = 24
.DistanceFromLeft = 24
.DistanceFromBottom = 24
.DistanceFromRight = 24
.Shadow = False
.EnableFirstPageInSection = True
.EnableOtherPagesInSection = True
.ApplyPageBordersToAllSections
End With
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth150pt
.DefaultBorderColor = wdColorAutomatic
End With
‘-------- 1.5 inç Sayfa Kenar Çizgisi silme_kaldırma ------
With Selection.Sections(1)
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
With .Borders
.DistanceFrom = wdBorderDistanceFromPageEdge
.AlwaysInFront = True
.SurroundHeader = True
.SurroundFooter = True
.JoinBorders = False
.DistanceFromTop = 24
.DistanceFromLeft = 24
.DistanceFromBottom = 24
.DistanceFromRight = 24
.Shadow = False
.EnableFirstPageInSection = True
.EnableOtherPagesInSection = True
.ApplyPageBordersToAllSections
End With
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth150pt
.DefaultBorderColor = wdColorAutomatic
End With
‘-------- 6 Karakteri İşaretleyip Renk Değiştirme ------
‘---- Unit:=wdWord, Count:=2 (2) Cümle
‘---- Unit:=wdCharacter, Count:=6 (6) harf


Selection.MoveRight Unit:=wdCharacter, Count:=6, Extend:=wdExtend
Selection.MoveRight Unit:=wdCharacter, Count:=1
‘-------- 6 Karakteri İşaretleyip Büyük Harfe Çevirme ------
Selection.MoveRight Unit:=wdCharacter, Count:=6, Extend:=wdExtend
Selection.Range.Case = wdUpperCase
Selection.MoveRight Unit:=wdCharacter, Count:=1
‘-------- 2 Cümleyi İşaretleyip Küçük Harfe Çevirme ------
Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
Selection.Range.Case = wdLowerCase
Selection.MoveRight Unit:=wdCharacter, Count:=1
‘-------- 2 Cümleyi İşaretleyip Başharfleri Büyük Yapma Harfe Çevirme ------
Selection.MoveRight Unit:=wdWord, Count:=2, Extend:=wdExtend
Selection.Range.Case = wdTitleWord
Selection.MoveRight Unit:=wdCharacter, Count:=1




  Alıntı
Bu mesajı beğenenler:
#2
Access dostlari adina, paylasim icin cok tesekkur ederim...



  Alıntı
Bu mesajı beğenenler:
#3
Yararlı olabilirsek ne mutlu bende faydalandığım bu site ve kullanıcılarına hocalara teşekkür ederim



  Alıntı
Bu mesajı beğenenler:
#4
sayın bibib merhaba;
word vba ile ilgili örnekleriniz oldukça bilgilendirici, istifade etmek üzere arşivime ekledim. öncelikle paylaşımınız için çok teşekkür ederim. aşağıdaki işlemleri yapabileceğim vba kodlarını paylaşabilirseniz çok memnun olacağım.

Çok düzeyli madde imleri ile hazırlanmış uzun bir word metni var. madde imleri şu şekilde;
1. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
a. xxxxxxxxxxxxxxxxxxxxxxxxxxx
b. xxxxxxxxxxxxxxxxxxxxxxxxxxx

2. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

3. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

4. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
a. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(1) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
(2) xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

yukarıdaki örnekte 1. - 2. - 3. ... şeklindeki ana maddeleri ve altındaki alt maddeleri de kapsayacak şekilde tabloda satırlarına taşımak istiyorum. yani;
1nci madde ve alt maddeleri tablonun birinci satırına,
2nci madde tablonun ikinci satırına,
3ncü madde tablonun üçüncü satırına,
4ncü madde ve alt maddeleri tablonun dördüncü satırına..
şeklinde tüm metni bu mantıkla tablonun satırlarına aktarmak için gerekli vba kodunu eğer mümkün ise açıklamalı olarak paylaşabilir misiniz?



  Alıntı
Bu mesajı beğenenler:


Benzer Konular...
Konu: Yazar Cevaplar: Gösterim: Son Mesaj
  Word Dot şaplonunu Açtırarak Dosya Göndermek Aplt 1 329 12-01-2025, 17:11
Son Mesaj: dsezgin
  [TABLO] Word Tablodan Tarih Aktarımı kahramanselim 6 509 01-10-2024, 12:34
Son Mesaj: halily
  [TABLO] Word Tablosundan Aktarım kahramanselim 4 350 26-09-2024, 00:32
Son Mesaj: halily
  [RAPOR] Access De Ki Raporu Word Belgesi Olarak Vba Kodu Ile Açma Ahmet51 10 879 01-08-2024, 10:28
Son Mesaj: dsezgin
  Ders Kodları Tablosundaki Alan Adlarına Göre öğrencinin Sınıfını Belirlemek .. programmer67 8 909 18-05-2023, 16:49
Son Mesaj: programmer67
  Raporda şablona Yazdırma ankaram 6 657 30-01-2023, 10:53
Son Mesaj: alperalper
  [SORGU] Aynı Kodları Barındıran Ama Bağlı Oldukları Alanları Farklı Iki Tabloyu Eşleştirme tarkanaykın 4 592 22-02-2022, 16:09
Son Mesaj: tarkanaykın
  [VBA] Access'ten Word'e Aldığım Her Bir Sayfayı Excel Sayfasına Aktarma abkbek 3 721 13-08-2021, 14:46
Son Mesaj: dsezgin

Foruma Git:


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