Make styles in tv-script visible by userform

  • Re: Urgent: Make styles in tv-script visible by userform

    Hi agian Cytop,
    Your code is absolutely brilliant. The form opens when I open the document. If you got time - I have two more question;

    1) In the subs for each of the checkbox click events - is it possible to simplfy the code more, i mean in stead of writing each name of the style, and each name of the control, is it possible to pull out the name of the control clicked, save it in a variable and use that variable instead? Would be much more easy to add or substract style "boxes" then.

    2) Add checkbox that makes "reports"? For example: If I add a checkbox called "Photographer" - the document selected choice of styles at once, like Heading1, Sceneheading, Synopsis and Photographer? And when turning off that chech box - the state of the UserForm returns to what was previously selected

    If you got time, I would be very grateful. Anyway - I am very happy for your help so far :)


  • Re: Urgent: Make styles in tv-script visible by userform

    Ahem - I took this one on as a little 'project' for myself. I've never worked with Word documents before so it's interesting for me too.

    What I've done (unfinished as yet though) is write an add-in so it will work with any document you load.

    It then shows you all the styles in the document and if they're used or not. You can also define which styles you want to track (remember, this will be on a per document basis). Once you define the styles you want to track, it'll show the form I uploaded yesterday with the styles to track listed as checkboxes. Selecting these checkboxes then hides/unhides text with that style.

    If you previously have defined styles to track for that document, it'll just show the userform from yesterday with an option to edit which styes you want to track.

    Adding style checkboxes would be automatic - this will just work with all existing styles and add/remove checkboxes depending on the styles you say to want to work with.

    Your Question 2 would need a little more work, but is very possible.

    Gods knows, even all the text in the user interface is in Norwegian (Thanks to Google translate) - if nothing else, that should give you a laugh or 2!

    It probably would not be finished today, but would you be interested if I finished that off?

  • Re: Urgent: Make styles in tv-script visible by userform

    Yes :) :). Thank you so much for spending your time on this. Meanwhile - is there a way to retrieve the name of the checkbox clicked - and put that in a variable - so for each style - i do not have to write every style, and every checkbox. Something like this? (I have tried, but get an error message - that this method is not supported)

    Private Sub chkSequence_Click()
    Dim [B]name[/B] as string
    [B]name[/B] =
    If [B]name[/B].Value = False Then
    ActiveDocument.Styles("[B]name[/B]").Font.Hidden = True
    ActiveDocument.Styles("[B]name[/B]").Font.Hidden = False
    End If
    End Sub

    Thank you anyway :).


  • Re: Urgent: Make styles in tv-script visible by userform

    All of that will be coded if I finish off that project... THe biggest problem you'll have is that EVERY checkbox has to have code behind it and that gets messy. I load the checkboxes dynamically rather than defining them on the userform and all the checkboxes will have a 'common' procedure to run when it's checked. It might be a little more complicated to setup, but once set up, it's self-maintaining and there's a lot less code overall.

    In your example, there's no need to try and query the name of the checkbox - you already know the Click event is for chkSequence, so you can just refer to chkSequence in the code. The problem is every checkbox needs a (modified) copy of that code behind it. That's the situation I'm avoiding altogether. It'll just be one procedure to handle clicks for all checkboxes - and that procedure will use code like you posted to determine the name of the checkbox...

  • Re: Urgent: Make styles in tv-script visible by userform

    I'll go finish it off then - probably be tomorrow before it's complete though.

    In the meantime, have a look at the attachment. What this does is load a different userform that lists all the Styles in the document and if they've been used or not. This stores the styles you want to track in the Advanced Document Properties - I've no idea what happens with the style names in Norwegian, but I have selected the styles Title and Normal. The checkboxes for these items should be selected. You can try editing the advanced properties and add in the Norwegian equivalents and see if that works, but remember this is only a sample.

    *EDIT* - there is code to save selected styles in that userform. So select one or 2 of the Norwegian style name that are used, click save and close the userform. Close the document and the 'Norwegian' styles should be selected when you re-open the document.

    Also - the document was saved as 97-2003 format because of the problems uploading 2007 docs last night. Just load as normal. If you save as 2010 (with macros) it should still work.

  • Re: Make styles in tv-script visible by userform

    Hi again there, Cytop. I have spent some hours now with formatting the styles, but when I try to run it the code halts. Do you think you could have a look at it (if you got time, of course). I wrote down all my style-names in the different paragraphs. I attach my document - which is actually yours :).

  • Re: Make styles in tv-script visible by userform

    Thank you so much for doing this work for me. And even translate it into norwegian (ha ha - it is correct, actually). I will try it :).

  • Re: Make styles in tv-script visible by userform

    Wow. It is not working yet, but what a work!! I get an error message saying there is "no documents open" when I open it. And how do I turn your code into an add-in in word? All the best.
    M :)

  • Re: Make styles in tv-script visible by userform

    Excuse me then while I delete all the attachments! $$$$$ :drunk:

    As I said before - if you want, I'll finish it off. It might take a little tinkering for 2010 but it'll work eventually!

  • Re: Make styles in tv-script visible by userform

    :music:Ha ha. This really works. I am looking forward to the day I got vba skills like this. I have just copied all my styles into An Opus (:)) - and it is just so cool to switch information on and off. You should have seen my script (20 pages, packed with info - prepared for one day of shooting). Your code even handle the toc: I can make it shorter or expand it just with a click. Fantastic!!! I am so grateful. How do I make this an add-in. by the way?

  • Re: Make styles in tv-script visible by userform

    Just one thing: I dont dare to touch your code without asking you - afraid of messing it all up. The userform1 is to small to show all my styles - how do I expand it? Another thing - rename it to "Velg stiler" (means "Show styles"). Proposal for upcoming feature; being able to apply style to the document via the UserForm1 - like a dashboard :). Thank you so much, mister.

    :) :) :)

  • Re: Make styles in tv-script visible by userform

    Mangle it if you want - there's more to do and as I mentioned before, this is the first time I've use Word VBA... so it's a learning curve for me too. I'm looking into making it an add-in. It might just be a template that's loaded automatically.

    That proposal is very possible, too...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!