Mache ich gerne:
Hier ein vollständiger Code:
Code: Alles auswählen
import xlwings as xw
#### Excel-Objekt für die Seite der Darstellung der Berechnung
book = xw.Book()
sheet = book.sheets[0]
sheet.name = 'Liste'
sheet = book.sheets.add(sheetName, after=book.sheets[-1])
for col in range(1, 15):
sheet.range(3, col).value = 'Grosser-Wert'
sheet.api.VPageBreaks(1).DragOff(Direction=xw.constants.Direction.xlToRight, RegionIndex=1)
Und das Ergebnis:
Code: Alles auswählen
---------------------------------------------------------------------------
com_error Traceback (most recent call last)
Cell In [7], line 13
10 for col in range(1, 15):
11 sheet.range(3, col).value = 'Grosser-Wert'
---> 13 sheet.api.VPageBreaks(1).DragOff(Direction=xw.constants.Direction.xlToRight, RegionIndex=1)
File ~\anaconda3\envs\excel\lib\site-packages\xlwings\_xlwindows.py:109, in COMRetryMethodWrapper.__call__(self, *args, **kwargs)
107 while True:
108 try:
--> 109 v = self.__method(*args, **kwargs)
110 if isinstance(v, (CDispatch, CoClassBaseClass, DispatchBaseClass)):
111 return COMRetryObjectWrapper(v)
File ~\anaconda3\envs\excel\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x9.py:40269, in VPageBreak.DragOff(self, Direction, RegionIndex)
40268 def DragOff(self, Direction=defaultNamedNotOptArg, RegionIndex=defaultNamedNotOptArg):
> 40269 return self._oleobj_.InvokeTypes(1420, LCID, 1, (24, 0), ((3, 1), (3, 1)),Direction
40270 , RegionIndex)
com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, None, None, None, 0, -2146827284), None)