Print .MPP file via VB

K

KitCaz

I have a code snippet to print Excel documents from Visual Basic. Can
someone provide similar code for printing PowerPoint files?

e.g. Excel code:

Dim ExcelApp, ExcelWb

Set ExcelApp = CreateObject("Excel.Application")
Set ExcelWb = ExcelApp.WorkBooks.Open("yourfile.xls")
ExcelWb.WorkSheets.PrintOut
ExcelApp.Quit
Set ExcelObj = Nothing
 
J

Jan De Messemaeker

Hi,

Isn't there a newsgroup about Power Point somewhere? This one is for
Microsoft Project.
Greetings,
 
J

Jan De Messemaeker

Hi,

I now see your title says .mpp files whereas the text says Power Point.
If it's mpp you mean, there is no way to "print an .mpp file"
You can print views, reports... but not '"the file"
What is it you want to achieve?
 
K

KitCaz

I crossed a brain wire somewhere. I definitely mean a Microsoft Project file.

I would like to open a .mpp file and print the e.g., the default view
automatically.
 
J

Jan De Messemaeker

OK, here we go:

Set PjApp=CreateObject ("MSProject.Application")
Pjapp.fileopen "FullAddressOfThe file"
Pjapp.fileprint

HTH
 
K

KitCaz

Works great! Pushing my luck to add, does the "fileprint" option always
prompt for options, or is there a way to optionally instruct it to accept all
defaults and not prompt?

Thanks so much!
 
J

Jan De Messemaeker

Hi Kitcaz,

Whire you're here already, why not look at Project's objects through the VBE
object browser?
Afte rthis one you'll probablly stumble on the next one..

Anyway, here's the help on FilePrint:

FilePrint Method


Prints the active view.

Syntax

expression.FilePrint(FromPage, ToPage, PageBreaks, Draft, Copies, FromDate,
ToDate, OnePageWide, Preview, Color)

expression Optional. An expression that returns an Application object.

FromPage Optional Integer. A number that specifies the first page to
print. The default value is 1.

ToPage Optional Integer. A number that specifies the last page to print.
The default is the last page in the project.

PageBreaks Optional Boolean. True if Microsoft Project uses manual page
breaks when printing. The default value is True.

Draft Optional Boolean. True if Microsoft Project prints the active view
in draft mode. The default value is False.

Copies Optional Integer. A number that specifies the number of copies to
print. The default value is 1.

FromDate Optional Variant. A number or string that specifies the first
date to print. The default is the start date of the project.

ToDate Optional Variant. A number or string that specifies the last date
to print. The default is the finish date of the project.

OnePageWide Optional Boolean. True if Microsoft Project prints only the
leftmost columns of the active view. The default value is False.

Preview Optional Boolean. True if Microsoft Project previews the active
view rather than printing it. The default value is False.

Color Optional Boolean. True if Microsoft Project prints the active view
in color. The default value is False.


All parameters are optional but it activates the Print Window
If you want to push Enter automatically you can use sendkeys:

sendkeys "~"
FilePrint

HTH
 
K

KitCaz

Yeah, I know it sounds like I'm being lazy, but truthfully, I am learning
pieces of Access along the way and not all of them are coming together at the
same time.

After you said that, I added MS Project as a reference and then got to know
the objects a little better. Thanks for all the tips. "Put one foot in
front of the other..." :)
 
J

Jan De Messemaeker

Excellent!
Doesn't mean you can't ask questions, to the contrary, but I expact they
will now be much more directed.
Greets,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top