Python Part 17b - VBA using pywin32

preview_player
Показать описание
By Andy Brown

If you'd like to help fund Wise Owl's conversion of tea and biscuits into quality training videos you can join this channel to get access to perks:

Chapters
00:00 Topic list
01:29 The VBA COM (Component Object Model)
03:29 A basic Excel VBA example
07:17 A basic Word VBA example
09:59 Translating a full Excel VBA program
20:38 Outlook: a digression on enumerations
22:42 Outlook: reading messages from mail folders
29:57: Outlook: downloading attachments

Рекомендации по теме
Комментарии
Автор

This is amazing!! Thank you so much, I'm learning a lot with your videos!!!

xaviruiz
Автор

Thanks Andy! So much to learn. Thumbs up!!

wayneedmondson
Автор

Hi. I want to copy a sheet from one workbook to another, while keeping the format using python. Would you know how to do that

gourabchakraborty
Автор

Andy, you have change the following:
number_oscars = input("Enter number of Oscars:" )
film_name = input("Enter name of film:" )
You need a gap between quote mark and the right bracket!

kcerny
Автор

Any way to get autocomplete in VS Code when working with COM objects?

Kralnor
Автор

Is there way to import Excel Range win32 directly to pd ??

mks
Автор

Thank you so much for your wonderful effort that help me to learn new stuff. Kindly keep continue.

I have a question on this. Tried to copy excel table and paste in Word as Pastespecial. I have tried "PasteSpecial(Link=True, DataType=wdPasteOLEObject)" gives me no attribute wdPasteOLEObjectfound error.

How we can handle this? Please help.

vetrivelr
Автор

Hi Andrew, Request you to upload a video on customizing ribbons without using custom UI editor and ribbon codes sub procedures

AmitdFatfit
Автор

Whoops, accidentally deleted my last post. Any tips for formatting PDFs with pywin32? I was able to create PDFs; however, not able to fit it to a page. I referenced a few scripts on stackoverflow and came up wit the code below, but still only fitting to half a page (not having the same issue if printing as PDF directly in Excel).

# Excel worbook name

wb_name='Test.xlsx'

# Set print area
print_area = 'A1:M37'

name_file = 'Sample_Dash'



outlook=

outlook.Visible = False

# Set tmp path

wb_path = f'{os.getcwd()}\\{wb_name}'

wb =

# Set Worksheet

ws = wb.Worksheets['Dash']

# Formatting

ws .PageSetup.Orientation = 1

ws.PageSetup.Zoom = False

# Issues here blow fitting to page, have no problem when printing to PDF in Excel though

ws.PageSetup.PrintArea = print_area

ws.PageSetup.FitToPagesTall = 1

ws.PageSetup.FitToPagesWide = 1

ws.PageSetup.LeftMargin = 25

ws.PageSetup.RightMargin = 25



# Save it

wb.ActiveSheet.ExportAsFixedFormat(0, pdf_path)

sully