newbie q - win32com.client and msproject

mcdonc at iqgroup.com mcdonc at iqgroup.com
Wed Sep 29 15:19:35 EDT 1999


I am having problems using win32com.client to open and save files in MS
Project.  I've used makepy to catalog the MS Project COM interface.
I'm hoping someone can help.  I don't even understand what its trying
to tell me.  Here's my code:

--- start code ---

o = win32com.client.Dispatch("MSProject.Application")
Name = "<C:\Program Files\Common Files\ODBC\Data Sources\MS-Project-
Test.dsn>\Project1"
Format = win32com.client.constants.pjMPP
Backup = 0
ReadOnly = 0
TaskInformation = 0
Filtered = 0
Table = ""
UserID = "sa"
DatabasePassword = ""
FormatID = ""

o.FileOpen(Name, 0, 1, 0, "", "", 0, UserID, DatabasePassword,
FormatID, "", "")

o.FileSaveAs(Name, Format, Backup, ReadOnly, TaskInformation, Filtered,
Table, UserID, DatabasePassword, FormatID)

---- end code ---

This code fails with the following:

--- start traceback ---

>>> Traceback (innermost last):
  File "C:\Program
Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in
RunScript
    exec codeObject in __main__.__dict__
  File "C:\WINNT\Profiles\saltv\Desktop\project.py", line 14, in ?
    o.FileOpen(Name, 0, 1, 0, "", "", 0, UserID, DatabasePassword,
FormatID, "", "")
  File "win32com\gen_py\A7107640-94DF-1068-855E-00DD01075445x0x4x2.py",
line 6304, in FileOpen
  File "win32com\gen_py\A7107640-94DF-1068-855E-00DD01075445x0x4x2.py",
line 2025, in _ApplyTypes_
ValueError: invalid literal for int():

--- end traceback ---

the FileOpen method for MS Project is documented as such:

-- begin FileOpen helpdoc --

FileOpen method

Opens a project or imports data.

Syntax

expression.FileOpen(Name, ReadOnly, Merge, TaskInformation, Table,
Sheet, NoAuto, UserID, DatabasePassWord, FormatID, Map, OpenPool)

expression		Optional. An expression that returns an
Application object.

Name		Required String. The name of the project file, source
file, or data source to open.

ReadOnly		Optional Boolean. True if the file is opened
read-only. If selectively importing data instead of loading a complete
project, ReadOnly is ignored.

Merge		Optional Long. Specifies whether to automatically merge
the file with the active project. If Map is specified, Merge is
ignored. Can be one of the following PjMerge constants: pjDoNotMerge,
pjMerge, pjAppend, or pjPrompt. The default value is pjDoNotMerge.

TaskInformation		Optional Boolean. True if the file contains
information on tasks, for a project saved under a non-Microsoft Project
file format. False if the file contains information on resources. If
Map is specified, TaskInformation is ignored. The default value is True
if the active view is a task view; otherwise it is False.

Table		Optional String. The name of a table in which to place
the resource or task information, for a project saved under a non-
Microsoft Project file format. If Map is specified, or Name specifies a
database file or format, Table is ignored. The default value for Table
is the name of the active table.

Sheet		Optional String. The sheet to read when opening a
workbook created in Microsoft Excel version 5.0 or later. If Map is
specified, or if the file specified with Name is not a Microsoft Excel
file, Sheet is ignored.

NoAuto		Optional Boolean. True if any Auto_Open macro is
prevented from running. The default value is False.

UserID		Optional String. A user ID to use when accessing a
database. If Name or FormatID isn't a database, UserID is ignored.

DatabasePassWord		Optional String. A password to use when
accessing a database. If Name or FormatID isn't a database,
DatabasePassWord is ignored.

FormatID		Optional String. The file or database format.
If Microsoft Project recognizes the format of the file specified with
Name, FormatID is ignored. Can be one of the following format strings:

Format String	Description
"MSProject.mpp"	Microsoft Project file
"MSProject.mpt"	Microsoft Project template
"MSProject.mpd"	Microsoft Project database
"MSProject.mpw"	Microsoft Project workspace
"MSProject.mpx"	Microsoft Project 4.0 MPX file
"MSProject.odbc"	ODBC database
"MSProject.xls5"	Microsoft Excel 5.0/95 (7.0) workbook
"MSProject.xls8"	Microsoft Excel 97 (8.0) workbook
"MSProject.mdb8"	Microsoft Access 97 (8.0) database
"MSProject.csv"	CSV file
"MSProject.txt"	TXT file
Map		Optional String. The name of the import/export map to
use when importing data.

OpenPool		Optional Long. The action to take when opening
a resource pool or sharer file. Can be one of the following PjPoolOpen
constants: pjPromptPool, pjPoolReadOnly, pjPoolReadWrite,
pjPoolAndShares, or pjDoNotOpenPool. The default value is pjPromptPool.

--- end FileOpen helpdoc ---

Can anyone lend a hand?



Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list