title: PermissionError: [Errno 13] Permission denied in openpyxl python
body: <p>I am creating Invoice generator using Tkinter python but I am getting permission error
  All the respective files were closed during program execution. In Tkinter window, once I click add button it shows the error which is mentioned below</p>
  <p>My program</p>
  <pre><code>from tkinter import *
  from openpyxl import load_workbook
  from datetime import date
  
  # from win32com import client
  wb = load_workbook('E://invoice.xlsx')
  sheet = wb['Sheet1']
  
  
  #Date 
  sheet.cell(row=7,column=6).value = date.today()
  #BILL NUMBER 
  temp = sheet.cell(row=8,column=6).value
  temp = int(temp[1:])
  new_no = temp+1
  sheet.cell(row=8,column=6).value = 'B0'+str(new_no)
  
  #Making Sheet values blank
  sheet.cell(row=8,column=1).value = &quot;&quot;
  for i in range(17,27):
      sheet.cell(row=i,column=1).value = None
      sheet.cell(row=i,column=3).value = None
      sheet.cell(row=i,column=4).value = None
  co=16     
  def get1():
      global co
      co+=1
      print(&quot;get&quot;)
      global ent1
      global ent2
      global ent3
      global ent4
      client_name = ent1.get()
      item = ent2.get()
      price = ent3.get()
      quantity = ent4.get()
      sheet.cell(row=8,column=1).value = client_name
      sheet.cell(row=co,column=1).value = item
      sheet.cell(row=co,column=3).value = price
      sheet.cell(row=co,column=4).value = quantity
      print(client_name,item,price,quantity)
      wb.save('E://invoice.xlsx')
  
  def pdf():
      global wb
      wb.close()
      from win32com import client
      from openpyxl import load_workbook
      wb = load_workbook('E://invoice.xlsx')
      sheet = wb['Sheet1']
      #sheet name
      bill_no = sheet.cell(row=8,column=6).value
      cus_name = sheet.cell(row=8,column=1).value
  
      input_file = r'E:invoice.xlsx'
      output_file = r'E:exel//'+(bill_no+'_'+cus_name)+'.pdf'
      app = client.DispatchEx(&quot;Excel.Application&quot;)
      app.Interactive = False
      app.Visible = False
      Workbook = app.Workbooks.Open(input_file)
      try:
          Workbook.ActiveSheet.ExportAsFixedFormat(0, output_file)
      except Exception as e:
          print(&quot;Failed to convert in PDF format.Please confirm environment meets all the requirements  and try again&quot;)
          print(str(e))
      finally:
          Workbook.Close()
  #     app.Exit()
  
      
      
  window = Tk(screenName = &quot;vcs&quot;,baseName = &quot;ver 1.0&quot;)
  window.geometry(&quot;500x500&quot;)
  window.title(&quot;Vaibhav Computer Services&quot;)
  widget = Label(window, text = &quot;Vaibhav Computer Services&quot;,fg='blue',font=(&quot;bold&quot;,16))
  widget.pack()
  
  
  lab1 = Label(window, text = &quot;Client Name :&quot;,fg='blue',font=(&quot;bold&quot;,16)).place(x=90,y=60)
  ent1 = Entry(window)
  ent1.place(x=230,y=65)
  
  lab2 = Label(window, text = &quot;Item  :&quot;,fg='blue',font=(&quot;bold&quot;,16)).place(x=90,y=100)
  ent2 = Entry(window)
  ent2.place(x=230,y=105)
  print(ent2)
  
  lab3 = Label(window, text = &quot;Price  :&quot;,fg='blue',font=(&quot;bold&quot;,16)).place(x=90,y=140)
  ent3 = Entry(window)
  ent3.place(x=230,y=145)
  # ent3.bind('&lt;KeyPress&gt;',keybind1)
  print(ent3)
  
  lab4 = Label(window, text = &quot;Quantity  :&quot;,fg='blue',font=(&quot;bold&quot;,16)).place(x=90,y=180)
  ent4 = Entry(window)
  ent4.place(x=230,y=185)
  print(ent4)
  
  #Button
  button1 = Button(window,text=&quot;Add&quot;,font=(&quot;bold&quot;),command=get1).place(x=250,y=230)
  
  button2 = Button(window,text=&quot;Generate PDF&quot;,font=(&quot;bold&quot;),command=pdf).place(x=200,y=290)
  window.mainloop()
  wb.save('E://invoice.xlsx')
  </code></pre>
  <p>All the respective files was closed during program execution</p>
  <p>Error</p>
  <pre><code>Exception in Tkinter callback
  Traceback (most recent call last):
    File &quot;c:\users\pranu\appdata\local\programs\python\python38-32\lib\tkinter\__init__.py&quot;, line 1883, in __call__
      return self.func(*args)
    File &quot;&lt;ipython-input-22-6691247dc7ef&gt;&quot;, line 44, in get1
      wb.save('E://invoice.xlsx')
    File &quot;c:\users\pranu\appdata\local\programs\python\python38-32\lib\site-packages\openpyxl\workbook\workbook.py&quot;, line 392, in save
      save_workbook(self, filename)
    File &quot;c:\users\pranu\appdata\local\programs\python\python38-32\lib\site-packages\openpyxl\writer\excel.py&quot;, line 291, in save_workbook
      archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)
    File &quot;c:\users\pranu\appdata\local\programs\python\python38-32\lib\zipfile.py&quot;, line 1251, in __init__
      self.fp = io.open(file, filemode)
  PermissionError: [Errno 13] Permission denied: 'E://invoice.xlsx'
  </code></pre>