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.

altert if style is used?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sydney - 17 Oct 2005 06:15 GMT
Hi

I am trying create a macro that prompt a message box only if a particular
style  has been used in a document.

Below is what I have tried, however, the message box appears regardless if
the style is in use or not:

Dim objStyle As Word.Style

With ActiveDocument
If objStyle.InUse And objStyle.NameLocal = "MyStyle" Then
MsgBox "Incorrect Style in use"
End If
End With

With thanks
Jezebel - 17 Oct 2005 07:32 GMT
First, the code is no good. You haven't set objStyle to refer to anything.
Should be

If ActiveDocument.Styles("MyStyle").InUse then ...

However, this doesn't test whether the style has been applied to anything.
Read Help on the InUse property: "True if the specified style is a built-in
style that has been modified or applied in the document or a new style that
has been created in the document. ... This property doesn't necessarily
indicate whether the style is currently applied to any text in the document.
For instance, if text that's been formatted with a style is deleted, the
InUse property of the style remains True. For built-in styles that have
never been used in the document, this property returns False."

You'll need to use Find, to search for any text with the particular style
applied to it.

> Hi
>
[quoted text clipped - 13 lines]
>
> With thanks
Greg - 17 Oct 2005 13:41 GMT
Sydney,

I am not sure if this will answer you question, but I  have a style
report macro on my website that might get you close:

http://gregmaxey.mvps.org/Style_Report.htm
Sydney - 18 Oct 2005 05:23 GMT
Thank you kindly.

> Sydney,
>
> I am not sure if this will answer you question, but I  have a style
> report macro on my website that might get you close:
>
> http://gregmaxey.mvps.org/Style_Report.htm
 
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.