Jump to content
Fórum Script Brasil
  • 0

[Errno 13] Permission denied:


Question

O código abaixo se destina a copiar texto de vários docx e colar, um seguido do outro, em um outro docx(Principal.docx.

Funciona bem para pequenos textos (10 linhas por exemplo); porém quando o texto é longo ele até copia parte do texto, porém dá erro:

File "d:/Documents/Cina/TRT 15/Estruturas/Python/Estrutura.py", line 13, in <module>

PermissionError: [Errno 13] Permission denied: 'D:\\Documents\\Cina\\TRT 15\\Estruturas\\Python\\Principal.docx'

Solicito ajuda para solucionar...

 

import os

from docx import Document

from tkinter import filedialog as dlg

 

Dir = (os.path.dirname(os.path.realpath(__file__))) #Diretório atual

path = dlg.askopenfilename()

document = Document(path)

 

for p in document.paragraphs:

    #print(p.text)

    doc=Document(Dir + '\Principal.docx')

    paragraph = doc.add_paragraph(p.text)

    doc.save((Dir) + '\Principal.docx') #salve-o no sistema de arquivos

    os.startfile((Dir) + '\Principal.docx') #abre o arquivo Principal.docx

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Cloud Computing


  • Forum Statistics

    • Total Topics
      149411
    • Total Posts
      645902
×
×
  • Create New...