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 / October 2005

Tip: Looking for answers? Try searching our database.

delete style and if style not found what to do....

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
donna - 26 Oct 2005 17:39 GMT
i am trying to delete few style from activedocument. The macro is in one of
the template and people create new document from there. At the end of
tabulation etc. people delete unwant styles. It's always style a, b and c to
delete. The macro deletes this a, b and c style but what coding I should
write if they hit button again.
Basically, I would like to run a macro and if style is not found it should
gives a pop up saying styles are been deleted instead of run time error which
says "styles not found"

Any help
Anne Troy - 26 Oct 2005 17:47 GMT
Paste your code, Donna. That way, it's easier for someone to edit it, than
to write it all over again.
************
Anne Troy
www.OfficeArticles.com

>i am trying to delete few style from activedocument. The macro is in one of
> the template and people create new document from there. At the end of
[quoted text clipped - 8 lines]
>
> Any help
donna - 26 Oct 2005 18:31 GMT
Application.OrganizerDelete Source:=ActiveDocument, Name:="Abstract",
Object:=wdOrganizerObjectStyles
Application.OrganizerDelete Source:=ActiveDocument, Name:="Indent",
Object:=wdOrganizerObjectStyles
Application.OrganizerDelete Source:=ActiveDocument, Name:="Caption",
Object:=wdOrganizerObjectStyles
Application.OrganizerDelete Source:=ActiveDocument, Name:="Caption
(Cont'd)", Object:=wdOrganizerObjectStyles
Application.OrganizerDelete Source:=ActiveDocument, Name:="Center",
Object:=wdOrganizerObjectStyles
Application.OrganizerDelete Source:=ActiveDocument, Name:="hidden",
Object:=wdOrganizerObjectStyles

I'm attaching the coding.

> Paste your code, Donna. That way, it's easier for someone to edit it, than
> to write it all over again.
[quoted text clipped - 14 lines]
> >
> > Any help
Jean-Guy Marcil - 26 Oct 2005 19:04 GMT
donna was telling us:
donna nous racontait que :

> Application.OrganizerDelete Source:=ActiveDocument, Name:="Abstract",
> Object:=wdOrganizerObjectStyles
[quoted text clipped - 10 lines]
>
> I'm attaching the coding.

'_______________________________________
Sub CleanUpStyles()

DeleteStyle "Caption"
DeleteStyle "Indent"
DeleteStyle "Caption"
DeleteStyle "Caption (Cont'd)"
DeleteStyle "Center"
DeleteStyle "hidden"

End Sub
'_______________________________________

'_______________________________________
Function DeleteStyle(StyleName As String)

On Error GoTo StyleDeleted
ActiveDocument.Styles(StyleName).Delete

Exit Function

StyleDeleted:
Err.Clear
MsgBox "The style """ & StyleName & """ has " _
   & "already been deleted.", vbExclamation, _
   "Style not in list"

End Function
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Jean-Guy Marcil - 26 Oct 2005 19:18 GMT
Jean-Guy Marcil was telling us:
Jean-Guy Marcil nous racontait que :

> donna was telling us:
> donna nous racontait que :
[quoted text clipped - 43 lines]
> End Function
> '_______________________________________

Ooops..
Of course, replace the first
   DeleteStyle "Caption"
with
   DeleteStyle "Abstract"

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

 
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.