473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating MS Word documents

micmast
144 100+
Hey everybody,

After looking on the internet, I found that a way to create word documents is using the win32com object.

The easy part is
winapp = win32com.client.Dispatch("Word.Application")
windoc = winapp.Documents.Add()

And as far as I have found you have the contents and font part, but how can I add images, tables, headers, footers, ...

Is there an API somewhere, or a book somewhere that would explain to me how this works?

I have found a link to the Word Object Model from Microsoft, but that is a bit of a mess to work with.

http://msdn.microsoft.com/en-us/library/bb244515.aspx

Thx in advance
Mar 17 '09 #1
2 7822
micmast
144 100+
After further research I found some interesting information that other people might find interesting too.

In your Lib/site-packages/win32com/client there is a tool that is called makepy.py
When you execute this file with python, you get a list with all the COM objects installed on the computer. Select the Word COM object and click OK. It will start generating a python file
if you open that file and look for the class _Application you see a list of available commands

Or

Expand|Select|Wrap|Line Numbers
  1. import win32com.client
  2. wordapp = win32com.client.Dispatch("Word.Application")
  3. wordapp.Visible=1
  4. wordapp.ListCommands()
  5.  
That should open a document with a list of all the commands you have available. Use the previous method to find additional arguments. Allthougt if somebody has any other references feel free to still post them here.
Mar 17 '09 #2
bvdet
2,851 Expert Mod 2GB
Thanks micmast for the information. I had to pass an integer argument to ListCommands() for it to work though.
Expand|Select|Wrap|Line Numbers
  1. wordapp.ListCommands(1)
Python 2.3.5
Mar 20 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: vinod | last post by:
Hi, I intend to send word documents thru mail to my clients. I don't want my clients to save the word document to there system and i don't want them to print the word documents. How can i...
6
by: Fred Glickman via AccessMonster.com | last post by:
I need to find a way to automatically create several Word docs from 1 access query. Example: I have a query which has 40 records in it according to my criterea. Let's say that it is employees....
12
by: enak | last post by:
I have found some code that shows how to convert an html form to Word. The message said to simply put the following in the Page_load: Response.ContentType = "application/ms-word"...
0
by: Deepankar Raizada | last post by:
Hi Can anybody tell me where i can get some samples codes for creating word documents in a asp.net application with document headers and footers, also creating tables and adding data to that...
3
by: richi | last post by:
Hello, i'm hoping that somebody can point me in the right direction with my problem. I have been tasked with creating a simple browser based application that will allow the user to upload Word...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
2
by: Tom | last post by:
I have tried three ways of opening word documents on my win95 machines. (Yes, my client still has some win95 machine) #1-With Response.AddHeader "Content-Disposition", "attachment;...
0
by: Eagle | last post by:
I am trying to change the linewidth of a page border, and keeping getting an error at the "wdLineWith075pt" For some reason, it only accepts the value of 24 like the left border. Yet when I print...
3
by: Brian Cryer | last post by:
A project I'm about to start on has a requirement to create word documents on the fly for download from the website. To date all the code examples I've found on the net use automation (and by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.