View Single Post
 
Old 06-20-2017, 07:48 AM
paul73 paul73 is offline Windows XP Office 2010 64bit
Novice
 
Join Date: Jun 2017
Posts: 2
paul73 is on a distinguished road
Default set headings in a VBA inserted text to use for index

Hey People, hope you can help me.

I made a VBA in Excel, where i have all my data, to generate a document in Word. By clicking a button in Excel a template word document is opened and info from excel is added to the word document. First a line of text is added, and then a few pics. That process is repeated several times.

I would like the line of text to be "heading 2" in word and the pics as "normal" so i only have to update my table of contents and get all the lines of text in there.

I've come up wuth this, but it doesn't work, it makes the whole document "normal"

Hope one of you has the answer!



Set range2 = appwd.ActiveDocument.Content

For i = 6 To Sheets.Count

range2.Collapse Direction:=wdCollapseEnd
range2.Style = "kop 2"
Worksheets(i).Range("AU20").Copy
Application.Wait (Now + TimeValue("0:00:01"))
range2.PasteSpecial Placement:=wdInLine, DataType:=wdPasteText
Application.CutCopyMode = False


'copy paste acties
For j = 1 To 6
range2.Collapse Direction:=wdCollapseEnd
range2.Style = "standaard"
Worksheets(i).Range(bereik(j)).Copy
Application.Wait (Now + TimeValue("0:00:01"))
range2.PasteSpecial Placement:=wdInLine, DataType:=wdPasteMetafilePicture
Application.CutCopyMode = False
Next j

Next i
Reply With Quote