Arkadaslar elimdeki dosyada cok sayida degisk Bookmark var. Bu bu bookmarklardan birtanesi "Date" bookmarki fakat bazen kullanicilar yanlislikla "Date" bookmarkini silip dosyayi oyle kaydediyor.
Ben tekrar o dosyayi acip tarhi macroyla degitirmek istiyorum. Asagidaki kodda yapmak
istedigim eger "Date" bookmark varsa onu sec ve Insert Date komutuyla tarigi guncellemek. Macronun bu kismi gayet guzel calisiyor. Yani "Date"bookmarki silinmemisse bir sorun yok.
Ama benim problemim eger "Date" bookmarki yoksa tarhi degistiremiyorum. Komutun "If ActiveDocument.Bookmarks.Exists("Date") = False Then" kismi calismiyor.
neden acaba? yardimci olabilirmisiniz.
If ActiveDocument.Bookmarks.Exists("Date") = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="Date"
Selection.InsertDateTime DateTimeFormat:="dd MMMM yyyy", InsertAsField:= _
False, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.Find.ClearFormatting
With ActiveDocument.Bookmarks
If ActiveDocument.Bookmarks.Exists("Date") = False Then
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Tax Point:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=3
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertDateTime DateTimeFormat:="dd MMMM yyyy", InsertAsField:= _
False, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
End If
End With
Saygilar
Ben tekrar o dosyayi acip tarhi macroyla degitirmek istiyorum. Asagidaki kodda yapmak
istedigim eger "Date" bookmark varsa onu sec ve Insert Date komutuyla tarigi guncellemek. Macronun bu kismi gayet guzel calisiyor. Yani "Date"bookmarki silinmemisse bir sorun yok.
Ama benim problemim eger "Date" bookmarki yoksa tarhi degistiremiyorum. Komutun "If ActiveDocument.Bookmarks.Exists("Date") = False Then" kismi calismiyor.
neden acaba? yardimci olabilirmisiniz.
If ActiveDocument.Bookmarks.Exists("Date") = True Then
Selection.GoTo What:=wdGoToBookmark, Name:="Date"
Selection.InsertDateTime DateTimeFormat:="dd MMMM yyyy", InsertAsField:= _
False, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.Find.ClearFormatting
With ActiveDocument.Bookmarks
If ActiveDocument.Bookmarks.Exists("Date") = False Then
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Tax Point:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=3
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertDateTime DateTimeFormat:="dd MMMM yyyy", InsertAsField:= _
False, DateLanguage:=wdEnglishUK, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
End If
End With
Saygilar
Son düzenleme:
