title: openpyxl from Python code throws error while trying to open .xlsx file path from a global variable
body: <p>with some help from here, I have written a python code to get input from user which is usually an excel document path and pass it on to other programs which opens the excel and do some operation.
  In the below code if I give the path directly in the openpyxl, it reads the document but when I try to pass the path via a variable it throws the below error.
  Could somebody help me out here?</p>
  <p>Error -
  openpyxl.utils.exceptions.InvalidFileException: openpyxl does not support .xlsx&quot; file format, please check you can open it with Excel first. Supported formats are: .xlsx,.xlsm,.xltx,.xltm</p>
  <pre><code>    import openpyxl
      import tkinter as tk
      
      class App(tk.Frame):
          def __init__(self,master=None,**kw):
              #Create a blank dictionary
              self.answers = {}
              tk.Frame.__init__(self,master=master,**kw)
      
              tk.Label(self,text=&quot;Give Input Sheet Path&quot;).grid(row=0,column=0)
              self.Input_From_User1 = tk.Entry(self)
              self.Input_From_User1.grid(row=0,column=1)
      
      
              tk.Button(self,text=&quot;Feed into Program&quot;,command = self.collectAnswers).grid(row=1,column=1)
      
          def collectAnswers(self):
              self.answers['Input_Path'] = self.Input_From_User1.get()
              global Input_Path
              Input_Path = self.answers['Input_Path']
              functionThatUsesAnswers(self.answers)
              
      
      def functionThatUsesAnswers(answers):
      print(&quot;Given Input Path &quot;, answers['Input_Path'])
      quit()
      def quit():
          root.destroy()        
      if __name__ == '__main__':
          root = tk.Tk()
          App(root).grid()
          root.mainloop()
      
      print(Input_Path)
      Input_path1 = ('r&quot;'+Input_Path+'&quot;')
      print(Input_path1)
      wb = openpyxl.load_workbook(Input_path1) # trying to open the open the input sheet from the below path
      #wb = openpyxl.load_workbook(r&quot;C:\Users\xxxx\OneDrive - xx.xx'x xx\xxx\xx\xxxx\xxx.xlsx&quot;)
  </code></pre>