Please help me: I have copied cells in the buffer from Excell, I just can’t do a special insert in Word. Here is a piece of code:
xl.Run("PERSONAL.xlsb!Macros1") #запуск макроса в открытом Excel xl.ActiveCell.CurrentRegion.Select() #выбираем все ячейки xl.Selection.Copy() #копируем в буфер word = win32com.client.Dispatch("Word.Application") word.Documents.Open('12345.doc') #запускаем нужный документ word.Selection.Find.Text = 'some_word' #ищем слово, которое надо заменить word.Selection.Find.Execute() word.Selection.PasteSpecial() #Тут заменяем что искали на содержимое буфера со специальной вставкой The problem is actually in the last line, I don’t know which parameter to pass to be inserted with the necessary formatting (in my case, you need PasteAsImage). At the English-language forum they asked a similar question to insert into Excel, a person could decide by writing xl.Selection.PasteSpecial (Paste = constants.xlPasteValues) , but with Vord I didn’t have it. I think that the clue is to look for link 1 here and link 2 here, but still nothing works. If I pass a parameter from the second link, for example like this: word.Selection.PasteSpecial (DataType = 4) , it is still inserted in the original formatting.