B
Bala
Hi
My word doc contain nearly 200 pages and and have nearly 500 bookmarks. From
vb the user will pick up the bookmarks. so after that i need to remove those
bookmark contents. so i am using the below code. its seems executing fine
with bookmark delete code. finally look at the doc, the content is not
deleted. i dont know where am i doing mistake. can anyone please look at the
code and let me know if anymistake on the code.
thanks
bala
code
Dim objWord As Object
Dim objwordtarget As Object
Set objWord = CreateObject("Word.application")
objWord.Documents.Open ("C:\AMAImpairment\AIRReport1.doc")
objWord.ActiveDocument.Repaginate
objWord.Application.Browser.Target = wdBrowsePage
objWord.ActiveDocument.Select
Selection.MoveStart Unit:=wdCharacter, Count:=1
objWord.Application.Browser.Target = wdBrowsePage
'************************************************
Dim cntfirst As Integer
cntfirst = 1
Dim blnfind As Boolean
For J = 0 To UBound(DefaultBkms)
For i = 0 To UBound(docPageNo)
If UCase(DefaultBkms(J)) = UCase(docPageNo(i)) Then
blnfind = True
Exit For
Else
blnfind = False
End If
Next
If blnfind = False Then
If objWord.ActiveDocument.Bookmarks.Exists(DefaultBkms(J)) =
True Then
objWord.ActiveDocument.Bookmarks(DefaultBkms(J)).Delete
End If
End If
blnfind = False
Next
objWord.ActiveDocument.Close wdSaveChanges
objWord.Quit
Set objWord = Nothing
My word doc contain nearly 200 pages and and have nearly 500 bookmarks. From
vb the user will pick up the bookmarks. so after that i need to remove those
bookmark contents. so i am using the below code. its seems executing fine
with bookmark delete code. finally look at the doc, the content is not
deleted. i dont know where am i doing mistake. can anyone please look at the
code and let me know if anymistake on the code.
thanks
bala
code
Dim objWord As Object
Dim objwordtarget As Object
Set objWord = CreateObject("Word.application")
objWord.Documents.Open ("C:\AMAImpairment\AIRReport1.doc")
objWord.ActiveDocument.Repaginate
objWord.Application.Browser.Target = wdBrowsePage
objWord.ActiveDocument.Select
Selection.MoveStart Unit:=wdCharacter, Count:=1
objWord.Application.Browser.Target = wdBrowsePage
'************************************************
Dim cntfirst As Integer
cntfirst = 1
Dim blnfind As Boolean
For J = 0 To UBound(DefaultBkms)
For i = 0 To UBound(docPageNo)
If UCase(DefaultBkms(J)) = UCase(docPageNo(i)) Then
blnfind = True
Exit For
Else
blnfind = False
End If
Next
If blnfind = False Then
If objWord.ActiveDocument.Bookmarks.Exists(DefaultBkms(J)) =
True Then
objWord.ActiveDocument.Bookmarks(DefaultBkms(J)).Delete
End If
End If
blnfind = False
Next
objWord.ActiveDocument.Close wdSaveChanges
objWord.Quit
Set objWord = Nothing