J
jerem
I went into the VBA Language Reference for Word but can't seem to find the
language to accomplish the below explanation with the below code, but I admit
I've only been in there for about 2 hours. I tried to get "t" from an
InputBox but keep getting a message that member doesn't exist or something to
that effect so . . .maybe somebody out there can make this process a little
speedier.
Explanation: what I want to do is be able to copy a preexisting style's
["Source"] attributes (as represented by t in the code that follows) to
another preexisting style ["Target"] but I don't want the "Target" style to
be hard coded but variable - that is, gotten from a response from a user via
an input box, if that's possible. As mentioned above, I've been trying to
figure that out looking at Methods (CopyFormatMethod -which gives an example
of copying from paragraph to paragraph) but I need a Copy Paragraph Style
Attribute Method [my terminology] and thus far I haven't come across that
yet. So, in the end if X1 is the Source, this will always be the style
copied from and be hard coded and if X2 is the Target, this will always be
gotten from the user and when all is said and done X2 will still be style X2
only with X1's "With t" attributes. Hope I've made that easy to funderstand.
As always, thanks for the help.
Sub CopyAttributesOfStyle()
Dim t As Style, s As Style
Set s = ActiveDocument.Styles("Source style")
Set t = ActiveDocument.Styles.Add("Target style")
With t
.BaseStyle = ""
.ParagraphFormat = s.ParagraphFormat
.Font = s.Font
.LanguageID = s.LanguageID
End With
End Sub
language to accomplish the below explanation with the below code, but I admit
I've only been in there for about 2 hours. I tried to get "t" from an
InputBox but keep getting a message that member doesn't exist or something to
that effect so . . .maybe somebody out there can make this process a little
speedier.
Explanation: what I want to do is be able to copy a preexisting style's
["Source"] attributes (as represented by t in the code that follows) to
another preexisting style ["Target"] but I don't want the "Target" style to
be hard coded but variable - that is, gotten from a response from a user via
an input box, if that's possible. As mentioned above, I've been trying to
figure that out looking at Methods (CopyFormatMethod -which gives an example
of copying from paragraph to paragraph) but I need a Copy Paragraph Style
Attribute Method [my terminology] and thus far I haven't come across that
yet. So, in the end if X1 is the Source, this will always be the style
copied from and be hard coded and if X2 is the Target, this will always be
gotten from the user and when all is said and done X2 will still be style X2
only with X1's "With t" attributes. Hope I've made that easy to funderstand.
As always, thanks for the help.
Sub CopyAttributesOfStyle()
Dim t As Style, s As Style
Set s = ActiveDocument.Styles("Source style")
Set t = ActiveDocument.Styles.Add("Target style")
With t
.BaseStyle = ""
.ParagraphFormat = s.ParagraphFormat
.Font = s.Font
.LanguageID = s.LanguageID
End With
End Sub