Radoslaw Poprawski
Active Member
- Joined
- Jun 19, 2021
- Messages
- 398
- Office Version
- 365
- Platform
- Windows
So I started to learn python,
Mostly cos it is in excel now, and looping, web scraping and SAP scripting seems way easier then in VBA.
anyway to the question:
when i run this code in VS code, it works and it is creating a file:
however, when i try the same code pasted to excel, im getting Error 13:
I trie even this method:
to specify the exact path to no avail.
and this too:
However with this the error is sitting on line 2,
so what am I doing wong?
Mostly cos it is in excel now, and looping, web scraping and SAP scripting seems way easier then in VBA.
anyway to the question:
when i run this code in VS code, it works and it is creating a file:
Python:
def main():
# Open a file for writing and create it if it doesn't exist
MyNewFile = open("testfile.txt", "w+")
however, when i try the same code pasted to excel, im getting Error 13:
I trie even this method:
Python:
new_file_Path = r"C:\Users\Kafelka\Desktop\test.txt"
new_file = open(new_file_Path, "w+")
and this too:
Python:
def CreateFile():
new_file_Path = r"C:\Users\Kafelka\Desktop\test.txt"
new_file = open(new_file_Path, "w+")
However with this the error is sitting on line 2,
so what am I doing wong?