I am building a programme to automate a process in Excel using xlwings.
The files I have to access include .xlsx, .xlsb and .xlsm formats
I have the following command:
wb = xw.Book(r"some_directory\file1.xlsx")
which runs fine.
But when I run any of the next two commands:
wb = xw.Book(r"some_directory\file2.xlsb")
I get the following error:
Input In [10], in <cell line: 1>() ----> 1 wb = xw.Book(r"some_directory\file2.xlsb")
File ~\Anaconda3\lib\site-packages\xlwings\main.py:682, in Book.init(self, fullname, update_links, read_only, format, password, write_res_password, ignore_read_only_recommended, origin, delimiter, editable, notify, converter, add_to_mru, local, corrupt_load, impl) 680 if not app: 681 app = App(add_book=False) --> 682 impl = app.books.open(fullname, update_links, read_only, format, password, write_res_password, 683 ignore_read_only_recommended, origin, delimiter, editable, notify, converter, 684 add_to_mru, local, corrupt_load).impl 685 elif len(candidates) > 1: 686 raise Exception("Workbook '%s' is open in more than one Excel instance." % fullname)
File ~\Anaconda3\lib\site-packages\xlwings\main.py:4278, in Books.open(self, fullname, update_links, read_only, format, password, write_res_password, ignore_read_only_recommended, origin, delimiter, editable, notify, converter, add_to_mru, local, corrupt_load) 4276 try: 4277 impl = self.impl(name) -> 4278 if not os.path.samefile(impl.fullname, fullname): 4279 raise ValueError( 4280 "Cannot open two workbooks named '%s', even if they are saved in different locations." % name 4281
) 4282 except KeyError:File ~\Anaconda3\lib\genericpath.py:100, in samefile(f1, f2) 94 def samefile(f1, f2): 95 """Test whether two pathnames reference the same actual file or directory 96 97 This is determined by the device number and i-node number and 98 raises an exception if an os.stat() call on either pathname fails. 99 """ --> 100 s1 = os.stat(f1) 101 s2 = os.stat(f2) 102 return samestat(s1, s2)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'some_directory\file2.xlsb'
How do I access file2.xlsb using xlwings?