How To Execute An Excel VBA Macro From Python

Поділитися
Вставка
  • Опубліковано 14 гру 2024

КОМЕНТАРІ • 138

  • @CodingIsFun
    @CodingIsFun  3 роки тому +7

    *I will be here in the comments section. For any issues, please provide your exact error message, and I will try to help.*

    • @praveendesu
      @praveendesu 2 роки тому

      I need to run macros against a workbook but the macros is in another workbook. can you provide a syntax for this

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      @@praveendesu Not sure if I understand your use case. Let's say you have 2 workbooks: A + B. Do you want to use Python to trigger a macro in Workbook A, and Workbook A will start the macro in Workbook B using VBA? Can you perhaps elaborate on what it is you're actually trying to achieve? Please provide some additional info. Thanks!

    • @praveendesu
      @praveendesu 2 роки тому

      @@CodingIsFun Yes, workbook A has data in it but doesn't have macro code. Workbook B is an empty excel file with only macro code in it. I will need to run macros on workbook A using macros from workbook B.
      I'm getting an error using this method, its saying that macros not found on workbookA.
      wb_A=xw.Book("FILE1.xlsx")
      wb_B=xw.Book("FILE2.xlsx")
      macro_A=wb_A.macro("'FILE2.xlsx'!Macro_Name") #pulling macros from workbookB
      macro_A()

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      @@praveendesu In that case, I recommend triggering the macro from workbook B via Python (as shown in the video).
      The macro in workbook B will then manipulate workbook A using VBA

    • @praveendesu
      @praveendesu 2 роки тому

      I've tried that method, since there is no data in workbook B. I'm getting an error saying that no data was selected. so from what I understood is that using your method in your video, we can only trigger macros within same workbook. we won't be able to trigger a macro from another workbook and apply that macro to the current workbook.
      However, if you could help me in passing a macro code directly into a workbook and trigger it, that would be great, instead of actually calling the macro of a workbook.

  • @dragosborosgpt
    @dragosborosgpt 3 роки тому +9

    very cool. as an improvement you can add after, the import command, the following python code "app = xw.App(visible=False)" This will run Excel in the background and will not obscure your PYTHON workflow with flickering Excel tasks

    • @CodingIsFun
      @CodingIsFun  3 роки тому +1

      Cool, thanks for the tip! 👍

    • @thanhsangnguyen9343
      @thanhsangnguyen9343 2 роки тому +1

      Could you explain more clear, give me the codes. I really need them. Thanks

    • @shubhambagdare6600
      @shubhambagdare6600 Рік тому

      ​@@thanhsangnguyen9343 just write the line 'app = xw.App(visible=False)' below the import xlwings line

  • @Rezzzn0r
    @Rezzzn0r 2 роки тому +2

    thank you so much for proper closing instruction! I've been fighting with this for several hours...

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Glad it was helpful. Thanks for watching

  • @James-ty7nl
    @James-ty7nl 2 роки тому +2

    hi sir, this set of code also work for activating macro from personal workbook?

    • @CodingIsFun
      @CodingIsFun  2 роки тому +2

      Thanks for watching. In my first attempts, it didn't work. That said, I have not extensively googled for a solution. So, there might be a way to execute a macro from a personal workbook.

    • @nczioox1116
      @nczioox1116 2 роки тому

      Have you figured out how to run from personal workbook? I have to send excel documents at work that are not allowed to be XLSM so need to run from personal workbook

    • @TStars11
      @TStars11 2 роки тому

      @@CodingIsFun I am also looking for a solution to run macro from a personal workbook. Have you figures out now?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      @@TStars11 I have not tested it further

  • @markbozinovic706
    @markbozinovic706 5 днів тому

    Great work, will try this. Could and likely to prove to be very useful. Will investigate debugging as well through python along with Power BI and Power Query capabilities.

  • @daniloortiz7530
    @daniloortiz7530 8 днів тому

    La ejecución puede ser en segundo plano ?

  • @vincentkoh3313
    @vincentkoh3313 3 роки тому +1

    As usual superb content.

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      I'm really happy to hear that, and thank you for taking the time to leave a comment!

  • @praldemir
    @praldemir 2 роки тому +1

    Very very beatiful!! You're helping me a lot! I'm from Brazil and studying Python into Knime. I have many macros and do this it will help me. Do you have videos about Python with knime?

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Glad you liked it. Thanks for watching. Unfortunately, I do not have any videos about Python with knime.

  • @KeyserTheRedBeard
    @KeyserTheRedBeard 2 роки тому +1

    nice video Coding Is Fun. I crushed that thumbs up on your video. Keep up the really good work.

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Thanks a lot! I appreciate your support! 👍

    • @KeyserTheRedBeard
      @KeyserTheRedBeard 2 роки тому +1

      @@CodingIsFun no problem at all. always happy to support my fellow content creators. i am looking forward to improving on my own current video format i have uploaded and, in the future, trying to create content as good as yours in the long term.

  • @ansariathar60
    @ansariathar60 5 місяців тому

    Thanks
    Vid was of great help.

    • @CodingIsFun
      @CodingIsFun  5 місяців тому

      Glad I could help! Thanks for watching! Cheers, Sven ✌️

  • @KhalilYasser
    @KhalilYasser 3 роки тому +1

    Amazing. Thanks a lot for all these great tutorials.

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      You're very welcome Yasser! Thank you for watching and for the comments!

  • @rajesh9sn
    @rajesh9sn 2 роки тому +1

    Hi, Thank you for sharing this. I been searching for this solution for a while now. You are the best.❤❤

  • @sandortundik1245
    @sandortundik1245 Рік тому

    Hi there, is there any similar stuff for executing Word macros as well? Thanks!

    • @CodingIsFun
      @CodingIsFun  Рік тому +1

      Thanks for watching. I assume, you can do it with the pywin32 package. Please note that I have not tested the code:
      import win32com.client as win32 # pip install pywin32
      from pathlib import Path
      # Path to the Word document containing the macro
      word_document_path = Path(r"C:\path\to\your\MyWordDocument.docm").resolve()
      # Initialize the Word Application
      word_app = win32.gencache.EnsureDispatch('Word.Application')
      # Open the Word document containing the macro
      word_document = word_app.Documents.Open(str(word_document_path))
      # Run the VBA macro
      word_app.Run('MyWordMacro')
      # Close the Word document and Quit the Word application
      word_document.Close(SaveChanges=0)
      word_app.Quit()
      Happy Coding! :)

    • @sandortundik1245
      @sandortundik1245 Рік тому

      @@CodingIsFun Thank you! I found a similar but way more complicated solution. I will definitely try this code as well. Thanks again!

  • @magnetriceric4468
    @magnetriceric4468 2 роки тому

    Hi Thanks for your sharing. However, how to run a macro code for another excel file. For example, I created empty excel by xlwings and then fill in some values in it. Now I wanna implement a macro code for that created excel file. How should I do?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!

  • @tester_1-o8f
    @tester_1-o8f 2 роки тому +1

    Really nice content, thank you for your work. My question to you is: How can we inject a vba file into any xlsm file?

    • @CodingIsFun
      @CodingIsFun  2 роки тому +2

      Thank you! Have a look at the following solution: stackoverflow.com/a/17257036
      I hope it helps!

    • @tester_1-o8f
      @tester_1-o8f 2 роки тому +1

      Thanks for the solution, but what I want is to do this using the xlwings module. How can I do that?

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      @@tester_1-o8f xlwings is just a wrapper of the win32com module. As far as I know, there is no method implemented to directly insert VBA code into an existing workbook.

  • @sebastianrubiocastillo9741
    @sebastianrubiocastillo9741 2 роки тому

    Is there a way to run a macro saved in PERSONAL wb into any excel file?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      I am not sure. I have not tested it out

  • @masontv0
    @masontv0 Рік тому

    Hi, how would I run multiple macros one by one in the same script? I am running them and it seems the second macro does not run. I think I need the first macro to complete before calling the second one maybe?

    • @CodingIsFun
      @CodingIsFun  Рік тому +1

      Thanks for watching. VBA is a single-threaded environment and you can't have two macros running at the same time.

    • @masontv0
      @masontv0 Рік тому

      ​@@CodingIsFun thank you for the quick response! Actually, I do no need to run the VBAs at the same time. My issue is that xlwings will timeout when running my VBA since xlwings is using applescripts which has a timeout of 120 seconds. Do you know how I can get around this issue or extend the timeout duration?

    • @CodingIsFun
      @CodingIsFun  Рік тому +1

      @@masontv0 To my knowledge, you cannot run VBA macros simultaneously, as VBA is single-threaded, as stated above. Regarding the timeout issue, you may want to break up your VBA code into smaller chunks and run each chunk separately. Otherwise, you might need to Google or check StackOverflow for a solution. Sorry that I cannot help here.

    • @masontv0
      @masontv0 Рік тому

      @@CodingIsFun Thank you. Breaking down to smaller chunks is what I ended up doing and I am not longer hitting the timeout. I haven't had much luck on Google or StackOverflow but I will keep looking to see if there is a way to extend this timeout period. Thanks again!

  • @taarigo6119
    @taarigo6119 2 роки тому

    Thank you, awesome video. I tried with my own vba macro, but I have a run time error '1004' reference isn't valid my which point a goalseek used in my macro. Please can use goalseek function in a macro and run macro from python just like your video?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thank you for watching the video & your suggestion.

  • @suveeshmalachiyil7655
    @suveeshmalachiyil7655 2 роки тому

    Hi, could you also help us to close vba message box using python script in the end when the macro is completed running.

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks for watching. I do not think closing the VBA Message from Excel using Pyhton is easily possible. I also do not know any use case for this.

  • @mesteban2702
    @mesteban2702 Рік тому

    excellent man!! Is there a way to click on the macro message with some code? thanks!!

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Thanks for watching. Sorry, but I am not sure what you mean.

  • @midhunmurali3709
    @midhunmurali3709 2 роки тому

    Great information, Thanks brother

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks for watching and your comment! :)

  • @zahidimranx
    @zahidimranx 2 роки тому

    I have one question, if you can support. I want to save excel range as png/jepg with VBA. its working fine if PC is unlocked. but once I lock the PC's screen, VBA is giving error (Selection.CopyPicture xlScreen, xlPicture) this doesn't work. can you please support

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Hard to tell from a distance why you are facing an error. Sorry that I cannot help.

    • @zahidimranx
      @zahidimranx 2 роки тому

      @@CodingIsFun No issue, Kindly keep in mind please ever you got idea. please share.

  • @theefiiny7771
    @theefiiny7771 5 місяців тому

    Can I ask a question? I didnt find anyone in the commments asking this, but...
    is it possible to create a fresh .xlsm workbook and add a macro to it and then execute it (with python ofcourse)?
    I have this problem: I create a new workbook where I want to create a graph from some data and employer wants this graph to be 3D pie chart. Iam able to make the graph a pie chart, however xlsxwrite or openpyxl doesnt support making 3Dpie chart.
    so my solution is to insert some VBA macro that would execute it for me. Is that possible?

    • @CodingIsFun
      @CodingIsFun  5 місяців тому

      Thanks for watching. Yes, that is possible with xlwings. Here is the sample script I created for you:
      gist.github.com/Sven-Bo/4253ad6ff739aa10137ce5d7185b119c
      I hope it helps! Cheers, Sven ✌️

    • @theefiiny7771
      @theefiiny7771 5 місяців тому

      @@CodingIsFun you're crazy. Two years later and you reply with a finished code in minutes :D. Thank you sooo much

    • @theefiiny7771
      @theefiiny7771 5 місяців тому

      @@CodingIsFun you deserve a coffee xD

    • @theefiiny7771
      @theefiiny7771 5 місяців тому

      @@CodingIsFun Damn, just tried it and I think it's a step in the right direction but I get this error:
      'Programmatic access to Visual Basic Project is not trusted
      '
      It ties to this line:
      vba_module = wb.api.VBProject.VBComponents.Add(1) # 1 stands for a VBA module
      Could it be something with my settings?

    • @theefiiny7771
      @theefiiny7771 5 місяців тому

      it was in settings. I fixed it, than you. it works

  • @deeshusvlog5802
    @deeshusvlog5802 Рік тому

    What of we need to run multiple macros with the same code

    • @CodingIsFun
      @CodingIsFun  Рік тому +1

      You could create a loop and execute the command inside the loop

  • @CM-ni5lb
    @CM-ni5lb 2 роки тому

    Does this mean Python actually waits for the instance to finish the execution before going to the next step like saving the workbook? Sorry, I just have this issue with batch files.

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      I am not sure. You might need to test it out.

  • @MegaGrac777
    @MegaGrac777 3 роки тому

    you're the best
    Great thx to you from France

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      Thank you! Greetings to France :)

  • @siyabonganxumalo4574
    @siyabonganxumalo4574 2 роки тому

    Can it also work with Macros in Microsoft Word?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks for watching. Not with xlwings, but you could use the pywin32 library.

  • @harrykout
    @harrykout 3 роки тому +1

    What has Marco done to you?
    Why execute?

  • @matheusosa
    @matheusosa 3 роки тому

    Amazing tutorial!!!

  • @iamtoqeerzafar
    @iamtoqeerzafar 2 роки тому

    Great information... can we also convert this python code to .exe (using pyinstaller)? We have a webscrapper macro, if we run it from python and then convert that python script to .exe will it work or the whole vba code should be replaced by python script in this case?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks. That could work. Best way to find out is to simply try it out ;) Happy Coding!

  • @AvinashKumar-xj8dp
    @AvinashKumar-xj8dp 2 роки тому

    Hi Sven,
    Can i run the Excel Macros through Python by not opening excel itself?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!

  • @Manish-zl9jh
    @Manish-zl9jh Рік тому

    can we use this in linux environment? and how?

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Thanks for watching. As far as I know, xlwings leverages the COM interface for Microsoft Excel, which is only available on Windows. On macOS, it uses AppleScript to interact with Excel. Hence, I guess it will not work on Linux

  • @taarigo6119
    @taarigo6119 2 роки тому

    Hi
    Thank you again for this video, I tried your method on linux server, but I have this message:
    xlwingsXlwings Error: Your platform only supports the instantiation via xw.Book(json)
    What does this mean?

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks for watching. As far as I know, xlwings does not work on a Linux server, as it uses the win32com interface under the hood to manipulate Excel files.

  • @calebhildbold240
    @calebhildbold240 3 роки тому

    Is there a way to run a macro that requires the user to select an .mdb file during the process?

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      Thanks for watching the video & your question.
      You could select the .mdb file within your macro, e.g. by using the msoFileDialogFilePicker
      wellsr.com/vba/2018/excel/vba-select-files-with-msoFileDialogFilePicker/
      I hope this helps!

  • @natarajduvvuri5215
    @natarajduvvuri5215 Рік тому

    Can we re use vba via python on different new files ?

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Thanks for watching. Sorry, but I don't know what you mean

  • @steaknpotatoeskins
    @steaknpotatoeskins 3 роки тому

    Hi, do you know how to 'select'/enable macros from python?

    • @steaknpotatoeskins
      @steaknpotatoeskins 3 роки тому

      com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', "Cannot run the macro ''test.xlsm'!Module1.testMacro'. The macro may not be available in this workbook or all macros may be disabled."...

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      @@steaknpotatoeskins Thanks for watching the video. Please see below a guide on how to enable macros in all workbooks via the Trust Center:
      www.ablebits.com/office-addins-blog/2020/03/11/enable-disable-macros-excel/
      After you have enabled all macros, it should work.

  • @prathvisingh8288
    @prathvisingh8288 Рік тому

    Suppose I have the VBA script saved as a ".bas" file. Is there a way to execute it for an excel file using python?

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Thanks for watching. According to ChatGPT that is possible, but I have not tried it out: chat.openai.com/share/cce2974a-50bc-4b7e-a00f-1bdd4fd188c6

    • @prathvisingh8288
      @prathvisingh8288 Рік тому

      @@CodingIsFun thank you for the prompt reply. I also ended up with the same solution as mentioned by you. Thanks again!

  • @BharatiyaFirstThanHinduMuslim
    @BharatiyaFirstThanHinduMuslim 6 місяців тому

    How to execute this same code using python exe or by batch .exe file?

    • @CodingIsFun
      @CodingIsFun  6 місяців тому +1

      Thanks for watching. Sorry, but I don't know what you mean. Cheers, Sven ✌️

    • @BharatiyaFirstThanHinduMuslim
      @BharatiyaFirstThanHinduMuslim 6 місяців тому

      @@CodingIsFun I think we can create a batch file (executable file in .exe format) for the same Python code and that can be executed directly from windows Folder.

    • @CodingIsFun
      @CodingIsFun  6 місяців тому +1

      @@BharatiyaFirstThanHinduMuslim Yes, you can compile to an executable file, e.g. by using "pyinstaller". Happy Coding!

    • @BharatiyaFirstThanHinduMuslim
      @BharatiyaFirstThanHinduMuslim 6 місяців тому

      @@CodingIsFun Thank you !! :-)

  • @rajkumarrajan8059
    @rajkumarrajan8059 Рік тому

    How can i write my path, if my path contains a special characters like space, "'"
    C:\Users\Your's Folder\excel.xlsx

    • @rajkumarrajan8059
      @rajkumarrajan8059 Рік тому

      i think we should use
      import xlwings as xw
      xb=xw.Book(r"C:\Users\Your's Folder\excel.xlsx")

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Thanks for watching. The following should work:
      from pathlib import Path
      import xlwings as xw
      excel_file = Path(r"C:\Users\Your's Folder\excel.xlsx").resolve()
      if not excel_file.exists():
      raise FileNotFoundError("The specified Excel file does not exist")
      wb = xw.Book(excel_file)

  • @Ettubrut
    @Ettubrut Рік тому

    Bless you, kind sir!

    • @CodingIsFun
      @CodingIsFun  Рік тому +1

      Glad I could help! Thanks for watching and for the kind words.

  • @nicholaschan202
    @nicholaschan202 2 роки тому

    Hi, it says "AttributeError: 'Workbook' object has no attribute 'macro' "

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Since version 0.7.1, the workbook object does have the attribute 'macro': docs.xlwings.org/en/stable/api.html?highlight=range#xlwings.Book.macro
      Ensure to upgrade your xlwings version by running "pip install xlwings --upgrade"
      Happy Coding!

  • @motiaelhajji8269
    @motiaelhajji8269 2 роки тому

    Thank you :)

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      You're very welcome! Thank you for watching and for the comment!

  • @manndipp
    @manndipp Рік тому

    Wooow, thanks a ton

    • @CodingIsFun
      @CodingIsFun  Рік тому

      An absolute pleasure, very happy to hear that you found it useful!

  • @gini77oo
    @gini77oo Рік тому

    genious, thanks!!!

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Glad you liked it. Thanks for watching.

  • @JoaoAlves-dg5cb
    @JoaoAlves-dg5cb 2 роки тому

    thank you!

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thank you for watching the video and taking the time to leave a comment!

  • @zahidimranx
    @zahidimranx 2 роки тому

    You are so great really.... Your videos supported my a lot.

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      Glad to hear that! Thanks for watching the video and your comment!

    • @zahidimranx
      @zahidimranx 2 роки тому

      @@CodingIsFun The beautiful thing is that you replies everyone. Keep it Up..............

    • @CodingIsFun
      @CodingIsFun  2 роки тому +1

      @@zahidimranx, I am trying my best to keep up with the comments, even tho I do not have a solution to every request/question. It is always great to see that people take the time to leave a comment under my video :)

    • @zahidimranx
      @zahidimranx 2 роки тому

      @@CodingIsFun Exactly Sir.. agreed with you, cannot fulfill every request. but again Thank you so much for your precious time for us.

  • @ahmedmetwaly1616
    @ahmedmetwaly1616 3 роки тому

    thank you so much :)

    • @CodingIsFun
      @CodingIsFun  3 роки тому

      A pleasure! Thanks for watching :)

  • @calmense7161
    @calmense7161 2 роки тому

    bester Mann

  • @JorgeFlores-ti7ou
    @JorgeFlores-ti7ou 2 роки тому

    thanks so much for your videos, Coding is Fun!
    however, iám trying to execute a very similar commands as yours in python 3.10 but some errors emerge like:
    Traceback (most recent call last):
    File "C:\file.py", line 1490, in
    import xlwings as xw
    File "C:\file\venv\lib\site-packages\xlwings\__init__.py", line 81, in
    from .udfs import (
    File "C:\Users\file\venv\lib\site-packages\xlwings\udfs.py", line 22, in
    import pythoncom
    File "C:\file\venv\lib\site-packages\pythoncom\__init__.py", line 1, in
    from _win32com import *
    ModuleNotFoundError: No module named '_win32com'
    Process finished with exit code 1
    hope you or anyone can help me on this!!
    cheers :)

    • @CodingIsFun
      @CodingIsFun  2 роки тому

      Thanks for watching. Could you try to run the following:
      a) 'pip install xlwings --upgrade'
      b) if [a] does not resolve the issue, please run 'pip install pywin32'

  • @santoshs7417
    @santoshs7417 16 годин тому

    Hi thanks a lot for this video❤ pls keep on continue ❤ one more thing I need a help how to pass the input parameters values from python variable to macro specific function pls share your what’s up or email I’d it’s better to follow up you ❤❤❤

  • @xButterCat
    @xButterCat Рік тому

    Hello! I have been able to reference this video successfully before to run my macros, but for some reason today I am receiving a traceback error while using this code. Do you know what the issue could be? I made sure that my libraries have been updated. It says I have a "Traceback error", then "com_error: (-2147417856, 'System call failed.', None, None)" The error message is below. Thank you for your amazing videos!
    com_error Traceback (most recent call last)
    C:\Users\username\AppData\Local\Temp/ipykernel_11712/2930032682.py in
    467 macro = wb.macro('FormatReport')
    468 macro()
    --> 469 wb.save()
    470 if len(wb.app.books) == 1:
    471 wb.app.quit()
    ~\Anaconda3\lib\site-packages\xlwings\main.py in save(self, path)
    871 if path:
    872 path = utils.fspath(path)
    --> 873 with self.app.properties(display_alerts=False):
    874 self.impl.save(path)
    875
    ~\Anaconda3\lib\site-packages\xlwings\main.py in app(self)
    839 .. versionadded:: 0.9.0
    840 """
    --> 841 return App(impl=self.impl.app)
    842
    843 def close(self):
    ~\Anaconda3\lib\site-packages\xlwings\_xlwindows.py in app(self)
    540 @property
    541 def app(self):
    --> 542 return App(xl=self.xl.Application)
    543
    544 def close(self):
    ~\Anaconda3\lib\site-packages\xlwings\_xlwindows.py in __getattr__(self, item)
    124 while True:
    125 try:
    --> 126 v = getattr(self._inner, item)
    127 if isinstance(v, (CDispatch, CoClassBaseClass, DispatchBaseClass)):
    128 return COMRetryObjectWrapper(v)
    ~\Anaconda3\lib\site-packages\win32com\client\__init__.py in __getattr__(self, attr)
    511 def __getattr__(self, attr):
    512 d=self.__dict__["_dispobj_"]
    --> 513 if d is not None: return getattr(d, attr)
    514 raise AttributeError(attr)
    515 def __setattr__(self, attr, value):
    ~\Anaconda3\lib\site-packages\win32com\client\__init__.py in __getattr__(self, attr)
    472 if args is None:
    473 raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
    --> 474 return self._ApplyTypes_(*args)
    475
    476 def __setattr__(self, attr, value):
    ~\Anaconda3\lib\site-packages\win32com\client\__init__.py in _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args)
    465 def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args):
    466 return self._get_good_object_(
    --> 467 self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
    468 user, resultCLSID)
    469
    com_error: (-2147417856, 'System call failed.', None, None)

    • @CodingIsFun
      @CodingIsFun  Рік тому

      Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.