How to use the organiser programatically

J

JB

Hi Folks,
I have a series of templates and wizards that I wish to be able to
re-create with options on a userform. Ideally I'd like to be able to
create styles and toolbars programatically but I'm told this can't be
done (if it can be please let me know :) ).

So what I'd like to do is write some code which can find my templates
and copy the styles, toolbars and modules/userforms to a new version of
the template. I think the organiser can be accessed using VBA but I'm
not sure about importing modules and forms.

Can anyone provide a sample of using the organiser and, if it can be
done, code to import modules and forms.

Any pointers appreciated.

J
 
J

Jonathan West

Hi JB,

You need to use the OrganizerCopy method. Provided that ther code is not in
a protected project, you can use the OrganizerCopy method to copy userforms
and modules between templates.
 
C

Chad DeMeyer

JB,

Jonathan supplied the method by which you can use the organiser
programmatically. However, I'd like to add that contrary to what you've
been told, you CAN create styles and toolbars programmatically.

FWIW
Chad
 
J

JB

Chad said:
JB,

Jonathan supplied the method by which you can use the organiser
programmatically. However, I'd like to add that contrary to what you've
been told, you CAN create styles and toolbars programmatically.

FWIW
Chad
Ahh, any chance you could supply a sample Chad?

J
 
C

Chad DeMeyer

To add a style:

Set oStyle = ActiveDocument.Styles.Add(Name:="Cool New Style",
Type:=wdStyleTypeParagraph)
With oStyle
With .Font
'font settings
End With
With .ParagraphFormat
'paragraph format settings
End With
'etc.
End With

To add a toolbar:

CustomizationContext = 'set this to a template or document object that
represents the template or document you want to save the toolbar with, or
use the constant NormalTemplate if you want to save it in Normal.dot

Set oCmdBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating,
Temporary:=True)
'Temporary argument above is optional, default is False, if set to True the
command bar is deleted when the container application is closed
With oCmdBar
.Controls.Add Type:=msoControlButton,
Id:=CommandBars("Edit").Controls("Paste").ID
'etc.
.Visible = True
End With

Hope that helps
Regards,
Chad
 
J

JB

Chad said:
To add a style:

Set oStyle = ActiveDocument.Styles.Add(Name:="Cool New Style",
Type:=wdStyleTypeParagraph)
With oStyle
With .Font
'font settings
End With
With .ParagraphFormat
'paragraph format settings
End With
'etc.
End With

To add a toolbar:

CustomizationContext = 'set this to a template or document object that
represents the template or document you want to save the toolbar with, or
use the constant NormalTemplate if you want to save it in Normal.dot

Set oCmdBar = CommandBars.Add(Name:="Custom", Position:=msoBarFloating,
Temporary:=True)
'Temporary argument above is optional, default is False, if set to True the
command bar is deleted when the container application is closed
With oCmdBar
.Controls.Add Type:=msoControlButton,
Id:=CommandBars("Edit").Controls("Paste").ID
'etc.
.Visible = True
End With

Hope that helps
Regards,
Chad
Thanks for your help folks, Both suggestions will be used!

Cheers

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top