Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Delete bookmark content

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bala - 07 Sep 2005 22:55 GMT
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
Bala - 07 Sep 2005 23:19 GMT
No problem. got it. this code will do.

If objWord.ActiveDocument.Bookmarks.Exists(DefaultBkms(J)) = True Then
                   objWord.ActiveDocument.Bookmarks(DefaultBkms(J)).Select
                   objWord.ActiveDocument.Bookmarks(DefaultBkms(J)).Delete
                   objWord.Selection.Delete
               End If

> Hi
>
[quoted text clipped - 50 lines]
>     objWord.Quit
>     Set objWord = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.