@@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!
@@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()
@@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
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.
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
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.
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
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.
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 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.
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! :)
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?
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 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.
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 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?
@@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.
@@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!
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?
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
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?
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 ✌️
@@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?
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.
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?
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!
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
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?
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.
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!
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."...
@@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.
@@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.
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)
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!
@@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 :)
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 :)
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'
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 ❤❤❤
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)
*I will be here in the comments section. For any issues, please provide your exact error message, and I will try to help.*
I need to run macros against a workbook but the macros is in another workbook. can you provide a syntax for this
@@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!
@@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()
@@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
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.
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
Cool, thanks for the tip! 👍
Could you explain more clear, give me the codes. I really need them. Thanks
@@thanhsangnguyen9343 just write the line 'app = xw.App(visible=False)' below the import xlwings line
thank you so much for proper closing instruction! I've been fighting with this for several hours...
Glad it was helpful. Thanks for watching
hi sir, this set of code also work for activating macro from personal workbook?
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.
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
@@CodingIsFun I am also looking for a solution to run macro from a personal workbook. Have you figures out now?
@@TStars11 I have not tested it further
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.
La ejecución puede ser en segundo plano ?
As usual superb content.
I'm really happy to hear that, and thank you for taking the time to leave a comment!
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?
Glad you liked it. Thanks for watching. Unfortunately, I do not have any videos about Python with knime.
nice video Coding Is Fun. I crushed that thumbs up on your video. Keep up the really good work.
Thanks a lot! I appreciate your support! 👍
@@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.
Thanks
Vid was of great help.
Glad I could help! Thanks for watching! Cheers, Sven ✌️
Amazing. Thanks a lot for all these great tutorials.
You're very welcome Yasser! Thank you for watching and for the comments!
Hi, Thank you for sharing this. I been searching for this solution for a while now. You are the best.❤❤
Great! Happy I could help!
Hi there, is there any similar stuff for executing Word macros as well? Thanks!
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! :)
@@CodingIsFun Thank you! I found a similar but way more complicated solution. I will definitely try this code as well. Thanks again!
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?
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!
Really nice content, thank you for your work. My question to you is: How can we inject a vba file into any xlsm file?
Thank you! Have a look at the following solution: stackoverflow.com/a/17257036
I hope it helps!
Thanks for the solution, but what I want is to do this using the xlwings module. How can I do that?
@@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.
Is there a way to run a macro saved in PERSONAL wb into any excel file?
I am not sure. I have not tested it out
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?
Thanks for watching. VBA is a single-threaded environment and you can't have two macros running at the same time.
@@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?
@@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.
@@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!
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?
Thank you for watching the video & your suggestion.
Hi, could you also help us to close vba message box using python script in the end when the macro is completed running.
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.
excellent man!! Is there a way to click on the macro message with some code? thanks!!
Thanks for watching. Sorry, but I am not sure what you mean.
Great information, Thanks brother
Thanks for watching and your comment! :)
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
Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
@@CodingIsFun No issue, Kindly keep in mind please ever you got idea. please share.
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?
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 ✌️
@@CodingIsFun you're crazy. Two years later and you reply with a finished code in minutes :D. Thank you sooo much
@@CodingIsFun you deserve a coffee xD
@@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?
it was in settings. I fixed it, than you. it works
What of we need to run multiple macros with the same code
You could create a loop and execute the command inside the loop
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.
I am not sure. You might need to test it out.
you're the best
Great thx to you from France
Thank you! Greetings to France :)
Can it also work with Macros in Microsoft Word?
Thanks for watching. Not with xlwings, but you could use the pywin32 library.
What has Marco done to you?
Why execute?
Oops 😅
Amazing tutorial!!!
Thank you! :)
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?
Thanks. That could work. Best way to find out is to simply try it out ;) Happy Coding!
Hi Sven,
Can i run the Excel Macros through Python by not opening excel itself?
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!
can we use this in linux environment? and how?
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
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?
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.
Is there a way to run a macro that requires the user to select an .mdb file during the process?
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!
Can we re use vba via python on different new files ?
Thanks for watching. Sorry, but I don't know what you mean
Hi, do you know how to 'select'/enable macros from python?
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."...
@@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.
Suppose I have the VBA script saved as a ".bas" file. Is there a way to execute it for an excel file using python?
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
@@CodingIsFun thank you for the prompt reply. I also ended up with the same solution as mentioned by you. Thanks again!
How to execute this same code using python exe or by batch .exe file?
Thanks for watching. Sorry, but I don't know what you mean. Cheers, Sven ✌️
@@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.
@@BharatiyaFirstThanHinduMuslim Yes, you can compile to an executable file, e.g. by using "pyinstaller". Happy Coding!
@@CodingIsFun Thank you !! :-)
How can i write my path, if my path contains a special characters like space, "'"
C:\Users\Your's Folder\excel.xlsx
i think we should use
import xlwings as xw
xb=xw.Book(r"C:\Users\Your's Folder\excel.xlsx")
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)
Bless you, kind sir!
Glad I could help! Thanks for watching and for the kind words.
Hi, it says "AttributeError: 'Workbook' object has no attribute 'macro' "
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!
Thank you :)
You're very welcome! Thank you for watching and for the comment!
Wooow, thanks a ton
An absolute pleasure, very happy to hear that you found it useful!
genious, thanks!!!
Glad you liked it. Thanks for watching.
thank you!
Thank you for watching the video and taking the time to leave a comment!
You are so great really.... Your videos supported my a lot.
Glad to hear that! Thanks for watching the video and your comment!
@@CodingIsFun The beautiful thing is that you replies everyone. Keep it Up..............
@@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 :)
@@CodingIsFun Exactly Sir.. agreed with you, cannot fulfill every request. but again Thank you so much for your precious time for us.
thank you so much :)
A pleasure! Thanks for watching :)
bester Mann
Danke!
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 :)
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'
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 ❤❤❤
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)
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.