Printing using VBA.

R

Ray McCoppin

Yes you can. Looks like this in VBA.

ViewApply Name:="&Gantt Chart"
FilePrint
ViewApply Name:="&Calendar"
FilePrint
 
J

John

Macrofinder said:
Can I open and print multiple views in Project using a macro?

Macrofinder,
Yes. But actually views aren't opened, project files are. The ViewApply
Method can then be used to activate any view and the FilePrint Method
can then be used to print the active view.

John
Project MVP
 
M

Macrofinder

Thank you so much Ray, however this is not working seemlessly for me, any
suggestions? I want to be able to walk away from the computer and have the
macro run w/ no delays. The print console comes up and I am unaware of how
to select ok using a macro. I have about 30 views to apply, and print.
Here's how my original code looks:

ViewApply Name:="SD ALAP"
ColumnBestFit Column:=2
ColumnBestFit Column:=3
ColumnBestFit Column:=4
ColumnBestFit Column:=5
ColumnBestFit Column:=6
ColumnBestFit Column:=7
FilePrint Copies:=1
ViewApply Name:="SD Deadline"
ColumnBestFit Column:=2
ColumnBestFit Column:=3
ColumnBestFit Column:=4
ColumnBestFit Column:=5
ColumnBestFit Column:=6
ColumnBestFit Column:=7
FilePrint Copies:=1
 
M

Macrofinder

Hi John. Thank you for the response. I understand how to apply a view and
print, however I am having difficulty applying multiple views and printing
them w/ out having to select "OK or Cancel," on the print console. I would
like to apply about 30 views and print them w/ out the computer stopping.
Here's how my code looks:

ViewApply Name:="SD ALAP"
ColumnBestFit Column:=2
ColumnBestFit Column:=3
ColumnBestFit Column:=4
ColumnBestFit Column:=5
ColumnBestFit Column:=6
ColumnBestFit Column:=7
FilePrint Copies:=1
ViewApply Name:="SD Deadline"
ColumnBestFit Column:=2
ColumnBestFit Column:=3
ColumnBestFit Column:=4
ColumnBestFit Column:=5
ColumnBestFit Column:=6
ColumnBestFit Column:=7
FilePrint Copies:=1
 
J

John

Macrofinder said:
Hi John. Thank you for the response. I understand how to apply a view and
print, however I am having difficulty applying multiple views and printing
them w/ out having to select "OK or Cancel," on the print console. I would
like to apply about 30 views and print them w/ out the computer stopping.
Here's how my code looks:

ViewApply Name:="SD ALAP"
ColumnBestFit Column:=2
ColumnBestFit Column:=3
ColumnBestFit Column:=4
ColumnBestFit Column:=5
ColumnBestFit Column:=6
ColumnBestFit Column:=7
FilePrint Copies:=1
ViewApply Name:="SD Deadline"
ColumnBestFit Column:=2
ColumnBestFit Column:=3
ColumnBestFit Column:=4
ColumnBestFit Column:=5
ColumnBestFit Column:=6
ColumnBestFit Column:=7
FilePrint Copies:=1
Macrofinder,
Ah, it seems I remember a similar question a few months ago. Normally
the FilePrint Method should execute without any further user input.
However for some reason the FilePrint Method really would like you to
specify the FromPage argument even though it is supposedly optional (as
are all the arguments). So be a nice guy and tell the nice computer
which page to start from. It will be happy, you will be happy and
everyone will win.

Hope this helps.
John
Project MVP
 
J

Jan De Messemaeker

Hi,

If it's just an ENTER the thing wants this is how you enter it in VBA:

Sendkeys "~"
FilePrint

Sendkeys BEFORE the print, no, I'm not mistaken :)
 
M

Macrofinder

Thank you so much. I was trying the Sendkeys, but not the one you indicated.
Your suggestion helped a great deal. Take care.
 
M

Macrofinder

Thanks John. Take care.

John said:
Macrofinder,
Ah, it seems I remember a similar question a few months ago. Normally
the FilePrint Method should execute without any further user input.
However for some reason the FilePrint Method really would like you to
specify the FromPage argument even though it is supposedly optional (as
are all the arguments). So be a nice guy and tell the nice computer
which page to start from. It will be happy, you will be happy and
everyone will win.

Hope this helps.
John
Project MVP
 

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