Seite 1 von 1

Excel VBA unter Python

Verfasst: Mittwoch 13. Dezember 2006, 16:44
von JeanCantos
Hallo zusammen,

mache gerade meine ersten Gehversuche mit Excel-Anwendungen unter Python.

Lässt sich eigentlich der "gesamte" Excel-VBA-Code auch unter Python nutzen?

Bei folgendem Code bekomme ich nämlich Probleme:

Code: Alles auswählen

# -*- coding: iso-8859-1 -*- 
import win32com.client
import string
from itertools import count

## Excel Anwendung öffnen
MyApplication = win32com.client.Dispatch("Excel.Application") 
MyApplication.Visible = True

## Arbeitsmappe auswählen oder neue erstellen
MyWorkbook = MyApplication.Workbooks.Open("D:\YVL 2.0_E1001_Bor.xls")

Tabellenname = MyApplication.Application.Caller.Parent.Name
MyWorkSheet = MyWorkbook.Worksheets(Tabellenname)
Den Versuch, den Tabellennamen zu ermitteln moniert Python mit der einer exceptions.AttributeError-Fehlermeldung: 'int' object has no attribute Parent.

Der VBA-Code

Code: Alles auswählen

Tabellename = Application.Caller.Parent.Name
funktioniert jedoch unter Excel.

Gruß,

Jean[/quote]