View Single Post
 
Old 06-22-2017, 01:12 AM
Artmax Artmax is offline Windows 10 Office 2016
Novice
 
Join Date: Jun 2017
Posts: 7
Artmax is on a distinguished road
Default

Hi GMayor,

I know i'm always coming with problems.
I've been testing them and hav ehad no issue except for the one that I put together (with your help of course), it works when applied to a single file but not when run over a folder. :\

Code:
Function changeStyle(oDoc As Document) As Boolean
    On Error GoTo Err_Handler
    oDoc.ApplyQuickStyleSet2 ("Template")
    changeStyle = True 'the name of the function = true
lbl_Exit:
    Exit Function
Err_Handler:
    changeStyle = False 'the name of the function = false
    Err.Clear
    GoTo lbl_Exit
End Function

(this may or may not be useful information for you)
I've looked over the web and there is very little written about ApplyQuickStyleSet2 but there are some contradictory examples of how to run it, I have tried different things while removing the error code catcher to see if I could learn anything (I didn't)

Code:
Function changeStyle(oDoc As Document) As Boolean
Dim Template As String


    
    'Do Something with oDoc here. e.g.,"
    oDoc.ApplyQuickStyleSet2 (Template)
    
End Function
This code seemed to be the most successful, in that it gave me a error that seemed to make sense.
"Run-Time Error 6209
Cannot load the requested Quick Style Set. Please check the set name and try again."

Even setting it to a standard word style set results in the same error, so may be nothing.

It seems strange that it would work only in one document and not across the folder (These are literally the same files and folder structure tested document to document and folder by folder)

Side note: not sure if this is possible as the macro recorder threw up nothing, but one or two of the documents had locked style sets, and obviously wouldn't work. Whne I manually opened them they were fine. Do you know of a way to unlock them in the code? - it's not a big deal and you hav ealready done so much.
Thank you again.
Reply With Quote