VB macro to build contents table for an Excel tagle that is transferred to Word

M

mikaelepstein

I have a large (= long and narrow) Excel table that is
transferred to Word usind a macro. Then, in Word the
another macro (in Excel)creates a table of contents in the
beginning of the table in Word. In Excel 2000 and Word
2000 this works fine, but in the 2002 versions th 0macro
does not start building the contents table.

I have, in the "This Workbook" module the following macro:

Private Sub Workbook_Open()
On Error Resume Next
Application.VBE.ActiveVBProject.References.AddFromFile "c:\
_Program Files\Microsoft Office\Office\MSWORD9.OLB"
On Error GoTo 0
End Sub

In Word 2002 VB the corresponding row reads
Application.VBE.ActiveVBProject.References.AddFromFile "c:\
_Program Files\Common Files\Microsoft Shared\Office10
\MS..."
but the message box is too short to show what comes after
MS in the row. I tried to type MSO.DLL but that didn't
work.

In a separate macro I define style to each heading (e.g.,
wdStyleHeading1)

adn, then in another macro I put the styles:

Sub Style_asetus (teksti, taso)
With wordApp.Selection
With.Find
..ClearFormatting
..Text = teksti
..Replacement.Text = ""
..Forward = true
..Wrap = wdFindContinue
..Excecute
End With
..Style = wordApp.ActiveDocument.Styles(taso)'stops here
..MoveRight Unit wdCharacter, Count:=1
..Find.ClearFormatting
End With
End Sub

The macro then stops a the row with 'stops here, and asks
for debugging.

What can I do ?

Waiting for an answer.

Mikael
 

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