Python Forum
win32com — How to resolve “AttributeError: xlUp” for Excel files?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
win32com — How to resolve “AttributeError: xlUp” for Excel files?
#1
Similar to Excel VBA, win32com has a 'xlUp' command. But do I use it? I tried the below code but get
AttributeError: xlUp

Or how do I find all the methods available in a Python library? Thanks in advance!

import win32com.client as wc xl=wc.DispatchEx("Excel.Application") wb=xl.Workbooks.Open(Filename='TEST', ReadOnly=False, UpdateLinks=0, IgnoreReadOnlyRecommended=True) ws=wb.Worksheets('sht1') print(ws.cells(ws.rows.count, 1).End(wc.constants.xlUp).Address)
Reply
#2
see: https://python-forum.io/thread-34648.html (your other thread)
I'm not a regular windows user so not sure if pywin32com is same, but is suspect so.
Reply
#3
(Aug-18-2021, 01:16 AM)JaneTan Wrote: Or how do I find all the methods available in a Python library?
>>> import win32com.client as wc >>> >>> dir(wc) ['CDispatch', 'CLSIDToClass', 'CastTo', 'CoClassBaseClass', 'Constants', 'Dispatch', 'DispatchBaseClass', 'DispatchEx', 'DispatchWithEvents', 'EventsProxy', 'GetActiveObject', 'GetObject', 'Moniker', 'Record', 'VARIANT', 'WithEvents', '_PyIDispatchType', '__WrapDispatch', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_event_setattr_', '_get_good_object_', '_get_good_single_object_', 'build', 'constants', 'dynamic', 'gencache', 'getevents', 'pythoncom', 'pywintypes', 'sys'] >>> >>> dir(wc.constants) ['__class__', '__delattr__', '__dict__', '__dicts__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__'] >>> >>> help(wc.constants) Help on Constants in module win32com.client object: class Constants(builtins.object) | A container for generated COM constants. | | Methods defined here: | | __getattr__(self, a) | | __init__(self) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined)
Using a good Editor(eg VS Code) or REPL function/method(with help) will automatic show when type wc.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to resolve FileNotFoundError llarkin6 6 1,654 Sep-29-2025, 05:45 PM
Last Post: noisefloor
  How to export files from spyder to excel? kranklin 3 1,822 Aug-04-2025, 08:51 PM
Last Post: kranklin
  Copy Paste excel files based on the first letters of the file name Viento 2 2,339 Feb-07-2024, 12:24 PM
Last Post: Viento
  [split] How to resolve version conflicts in Python? atonalwilson 1 2,147 May-04-2023, 09:02 AM
Last Post: buran
  How to resolve version conflicts in Python? taeefnajib 0 4,036 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  How to loop through all excel files and sheets in folder jadelola 1 12,512 Dec-01-2022, 06:12 PM
Last Post: deanhystad
  Creating csv files from Excel file azizrasul 40 17,308 Nov-03-2022, 08:33 PM
Last Post: azizrasul
  How to resolve my problem in Pycharm? bshoushtarian 0 1,762 Sep-26-2022, 11:45 AM
Last Post: bshoushtarian
  Solving equation equal to zero: How to resolve the syntax error? alexfrol86 3 3,812 Feb-21-2022, 08:58 AM
Last Post: deanhystad
  Working with excel files arsouzaesilva 6 5,427 Sep-17-2021, 06:52 PM
Last Post: arsouzaesilva

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.