0
votes

I'm trying to write to a word document from Excel using VBA. However when i try to apply the style heading 1 to the text it has to be English version of Office. How can i refer to the built in styles of office?

This is what i got now:

wrdApp.Selection.Style = "Heading 1"
wrdApp.Selection.TypeText Text:= "Test heading"

I want something similar to this (to make it international), however this does not work:

wrdApp.Selection.Style = WdBuiltinStyle.wdStyleHeading1
wrdApp.Selection.TypeText Text:= "Test heading"
1

1 Answers

2
votes

You have the right idea. Try simply:

wrdApp.Selection.Style = wdStyleHeading1

or without the reference to Word/late binding, use constant value

wrdApp.Selection.Style = -2

A list of enumerations can be found here:

http://msdn.microsoft.com/en-us/library/office/aa211923(v=office.11).aspx