Hallo zusammen,
ich habe mir aus dem Netz ein Makro kopiert, mit dem ich Punktkoordinaten in eine Excelliste einlesen möchte, leider wird mir ein Fehler ausgeworfen.
Ich habe nicht so seeeehr viel Ahnung vom skripten, fuxe mich da erst gerade rein, wäre sehr nett, wenn ihr mir helfen könntet.
Folgende Zeilen werfen mir ein Fehler aus:
OutputFile = Left(ThisApplication.ActiveDocument.FullFileName, _
Len(ThisApplication.ActiveDocument.FullFileName) - 4) + "_Arbeitspunkte.xls"
Der Fehler dazu lautet: "Laufzeitfehler '5': Ungültiger Prozeduraufruf oder ungültiges Argument"
Hier auch nochmal das ganze Skript.
Sub ExportArbeitspunkte()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition
Dim oWorkpoints As WorkPoints
Dim oWP As WorkPoint
Dim oP As Point
'get all workpoints in this part
Set oWorkpoints = oDef.WorkPoints
'Create a new Excel instance
Dim oExcelApplication As Excel.Application
Set oExcelApplication = New Excel.Application
'create a new excel workbook
Dim oBook As Excel.Workbook
Set oBook = oExcelApplication.Workbooks.Add()
Dim oSheet As Excel.WorkSheet
Set oSheet = oBook.ActiveSheet
Dim nRow As Integer
nRow = 1
'write the coordinates into separate columns, one workpoint each row
For Each oWP In oWorkpoints
Set oP = oWP.Point
oSheet.Cells(nRow, 1) = oP.X * 10
oSheet.Cells(nRow, 2) = oP.Y * 10
oSheet.Cells(nRow, 3) = oP.Z * 10
nRow = nRow + 1
Next
Dim OutputFile As String
OutputFile = Left(ThisApplication.ActiveDocument.FullFileName, _
Len(ThisApplication.ActiveDocument.FullFileName) - 4) + "_Arbeitspunkte.xls"
On Error Resume Next
oBook.SaveAs (OutputFile)
oBook.Close
Set oBook = Nothing
Set oSheet = Nothing
Set oExcelApplication = Nothing
MsgBox "Es wurde eine Excel Tabelle im aktuellen Verzeichnis erstellt und eine neue IPT für den Import geöffnet!"
'Make a new part file
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
End Sub
Gruß Marius
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP