Fill in existing dialog boxes programmatically

M

MiNK2781

Hello all

I am writing a vba routine to help me create a pdf file of upcoming tasks
(looking say 2 weeks ahead) for each member of the team, and then want to
email this out to each of them (each member see the tasks they should be
working on for the next 2 weeks) - all done automatically.

I'm using a number of the filters (e.g. Using Resource ...) and this brings
up a dialog box with a drop down list of the resources to choose from.

Any idea how I can either choose the name programatically, or how to bypass
this dialog box? I don't know the name of the box. I've tried various things
such as SendKeys but with no luck.

Any help would be appreciated. Of course if there is some other way to do
this task that is already available, I would appreciate any pointers.

Cheers

MiNK
 
J

JulieS

Hello MiNK,
Have you considered the use of custom views which can be created
with filters already applied? Create the filters for each of the
team, create a custom view using the custom filter. Then call to
the view in the routine.

I hope this helps. Let us know how you get along.

Julie
Project MVP

Visit http://project.mvps.org/ for the FAQs and additional
information about Microsoft Project
 
M

MiNK2781

Julie

Thanks for the quick response.
I had considered this sort of approach. Trouble is, that for each of my team
members (admittedly only 6 at the moment) I have to manually select the
resources name etc.
Addtionally when I come to print the filtered view to file, I need to enter
a file name. I can select the printer with FilePrintSetup OK, but using
FilePrint brings up a system window. I'd like to be able to programmatically
gain access to these windows.

Any thoughts?

Cheers
MiNK
 
J

JulieS

My thoughts are few but I'll share what little I know :)

My suggestion of creating views would be to allow you to simply
select the view instead of having to select a specific filter. If
the views are created with the filters applied in the view
definition, you can simply call to the view through

ViewApply Name:= "Your view name here"

In a quick search of this newsgroup it appears from prior posts on
the topic of "Convert MSProject to PDF" from March 10 of this year,
that there isn't a method to specify the file name when using File
Print. Jim Askel (MVP) wrote:

"There is no method to specify the file name when using FilePrint.
I also
checked the FileSaveAs in the Object Browser and PDF is not a
supported
format in VBA.

You are going to have to intercept the call from Windows as printing
is a
Windows service not Project. As such, I believe you may need to
investigate
using a .NET solution. "

I'm afraid I'm out of solutions, perhaps someone more knowledgeable
than I will weigh in.

Julie
 
M

MiNK2781

Julie

Many thanks for your help.
I suppose at least I now know that I wasn't simply missing something.

I had searched the forum, but not specifically for PDF - hence I missed the
post you refer to.

I may need to re-think my approach (or contimue to do the task manually).

If anyone has any other thoughts, I'd be grateful for them.

Cheers

MiNK
 
J

Jack Dahlgren MVP

This is something I worked out a few years back. It does most of what you
want so.

Sub PrintResourceCharts()
'This macro will pring a gantt chart for every resource in the project
'It will automatically adjust the timescale to show all of the resource's
activities
'Copyright Jack Dahlgren, Feb. 2002

Dim r As Resource
Dim mystring As String
ViewApply Name:="&Gantt Chart"
For Each r In ActiveProject.Resources
If r.Assignments.Count > 0 Then
mystring = r.Name
FilterEdit Name:="Filter 1", TaskFilter:=True, Create:=True, _
OverwriteExisting:=True, FieldName:="Resource Names", test:="Contains
exactly", _
Value:=mystring, ShowInMenu:=False, ShowSummaryTasks:=False
FilterApply "Filter 1"
SelectAll
ZoomTimescale Selection:=True
SendKeys "{ENTER}"
FilePrint
MsgBox (r.Name)
End If
Next r
End Sub

jack Dahlgren
http://zo-d.com/blog
 
R

Rod Gill

HI,

Two things:
1) you need to find a pdf writer that either saves the pdf file
automatically to the same folder as your project file (but with .pdf
extension) or has a programmable interface (such as Adobe Acrobat).
2) To print for each Resource record a macro of you manually creating a
Filter that selects tasks for a resource and the required date range. Now
edit the code to use a variable with your resource name and calculate the
date range required.

This is in fact one of the many sample bits of code in my book, but it's
easy to do once you get the start point from recorded code.

--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 
M

MiNK2781

Jack

Many thanks for the code.
Whilst is doesn't quite do what I want, it may help me to work out an
alternative solution.

Do I take it that SendKeys needs to be set BEFORE the dialog appears
(presumably the data is stored in the keyboard buffer and once the dialog
opens - it sits and waits for data from the keyboard?). Should this work for
a file path name i.e could I set the filename and path up and use sendkeys,
THEN try to initiate a print to pdf?

Cheers
Mike
 
J

Jack Dahlgren MVP

Yes, the SendKeys goes before. This is the tricky part.
You will have to experiment with how the dialog box works (tab order etc.)
to see if you can get it working for something complex.

I'd also try working with the EditCopyPicture

EditCopyPicture Object:=False, ForPrinter:=0, SelectedRows:=1,
FromDate:="6/8/09 12:00 AM", ToDate:="7/12/09 12:00 AM",
ScaleOption:=pjCopyPictureShowOptions, MaxImageHeight:=-1#,
MaxImageWidth:=-1#, MeasurementUnits:=2

that puts a gif on the clipboard. You could then use

application.MailSend(To, Cc, Subject, Body, Enclosures, IncludeDocument,
ReturnReceipt, Bcc, Urgent, SaveCopy, AddRecipient)

to send it out.

-Jack Dahlgren
 

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