Word 2013 Absturz mit PasteSpecial aus Excel
27.02.2014 20:11:21
Tobias
Gerne bitte ich um eure Hilfe. Der folgende Code funktioniert problemlos mit Office 2007 und Office 2010, nicht aber bei Office 2013. Die Zeile mit PasteSpecial bringt Word zum Absturz.
********************************************
Option Explicit
Dim WordApp As Word.Application
____________________________________________
Sub PicToWord()
Dim doc As Word.Document
Dim iIndex As Integer
Set WordApp = CreateObject("Word.Application")
With WordApp
.Visible = True
Set doc = .Documents.Add
Set doc = .ActiveDocument
End With
iIndex = WordApp.Documents.Count
Set doc = WordApp.Documents(iIndex)
ThisWorkbook.Worksheets("Tabelle1").Shapes("logogruen").Copy
With doc.Sections(1).Headers(wdHeaderFooterPrimary).Range
.Tables.Add Range:=doc.Sections(1).Headers(wdHeaderFooterPrimary).Range, NumRows:=2, _
_
NumColumns:=2, DefaultTableBehavior:=wdWord9TableBehavior ', AutoFitBehavior:=wdAutoFitContent
.Tables(1).Cell(Row:=1, Column:=1).Merge MergeTo:=.Tables(1).Cell(Row:=2, Column:=1) _
_
.Tables(1).Columns(1).Width = WordApp.CentimetersToPoints(9.5)
.Tables(1).Columns(2).Width = WordApp.CentimetersToPoints(7.5)
.Tables(1).Cell(1, 1).Range.PasteSpecial
.Tables(1).Cell(1, 2).Range.Text = "Titel 1"
.Tables(1).Cell(2, 2).Range.Text = "Untertitel"
.Tables(1).Borders.InsideLineStyle = wdLineStyleNone
.Tables(1).Borders.OutsideLineStyle = wdLineStyleNone
End With
Set WordApp = Nothing
Set doc = Nothing
End Sub
**********************************************
An was könnte das liegen? Ausprobiert habe ich schon "Paste" (mit dem selben Ergebnis) und "PasteAndFormat" (was mir aber ein anderes Problem generiert). Bin Rat los :(
Ich hoffe, ich bin mit meiner Anfrage in diesem Forum richtig, auch wenn der kritische Code-Teil Word betrifft... Weiss momentan einfach nicht weiter...
Danke für jede Hilfe!!
Tobias