Programming Word

M

Markus

I use OLE to offer Word as an editor for Rich Text and HTML from within my
app. I would like to extend this and write in info at the top of the Word
screen above the actual document.

That is, I would like to programmatically enter a TO, FROM, SUBJECT above
the actual body of the document that is not part of the document, and that
displays below the existing toolbars and above the document body, much like
Outlook does with email. In some cases, the user need not make edits to
this, but it is only for display.

Does anyone know if this is even possible? Does anyone know of a reference
book or article to help me complete this task, or any other advice?

Thanks for any and all ideas on this,
Mark
 
J

Jean-Guy Marcil

Markus said:
I use OLE to offer Word as an editor for Rich Text and HTML from within my
app. I would like to extend this and write in info at the top of the Word
screen above the actual document.

That is, I would like to programmatically enter a TO, FROM, SUBJECT above
the actual body of the document that is not part of the document, and that
displays below the existing toolbars and above the document body, much like
Outlook does with email. In some cases, the user need not make edits to
this, but it is only for display.

Does anyone know if this is even possible? Does anyone know of a reference
book or article to help me complete this task, or any other advice?

Thanks for any and all ideas on this,

I do not think you can create a "tall" toolbar that is docked... There maybe
a way, but I have never had the need so I have never looked into it...

Meanwhile, you can create three stacked toolbars...:

Option Explicit

Sub myToolbar()

Dim barData As CommandBar
Dim ctrlBar As CommandBarControl

CustomizationContext = ActiveDocument

Set barData = Application.CommandBars.Add("MyTOBar", msoBarTop, False, False)
With barData
.Visible = True
Set ctrlBar = .Controls.Add(Type:=msoControlButton)
With ctrlBar
.Width = System.HorizontalResolution * 0.05
.Caption = "TO:"
.Style = msoButtonCaption
End With
Set ctrlBar = .Controls.Add(Type:=msoControlEdit)
With ctrlBar
.Width = System.HorizontalResolution * 0.93
.Text = "Some text from elsewhere"
End With
End With

Set barData = Application.CommandBars.Add("MyFROMBar", msoBarTop, False,
False)
With barData
.Visible = True
Set ctrlBar = .Controls.Add(Type:=msoControlButton)
With ctrlBar
.Width = System.HorizontalResolution * 0.05
.Caption = "FROM:"
.Style = msoButtonCaption
End With
Set ctrlBar = .Controls.Add(Type:=msoControlEdit)
With ctrlBar
.Width = System.HorizontalResolution * 0.93
.Text = "Some other text from elsewhere"
End With
End With

Set barData = Application.CommandBars.Add("MySUBJECTBar", msoBarTop, False,
False)
With barData
.Visible = True

Set ctrlBar = .Controls.Add(Type:=msoControlButton)
With ctrlBar
.Width = System.HorizontalResolution * 0.05
.Caption = "SUBJECT:"
.Style = msoButtonCaption
End With
Set ctrlBar = .Controls.Add(Type:=msoControlEdit)
With ctrlBar
.Width = System.HorizontalResolution * 0.93
.Text = "Some more text from elsewhere"
End With
End With

End Sub
 

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