Import filtered data from Project to Excel using VBA not filters/

  • Thread starter Ian H - Project Swat
  • Start date
I

Ian H - Project Swat

I have borrowed some code off the net (it was free by the way but can't find
the chap's name at present) that imports project data in to an excel template
I created that has conditional formatting and variable name ranges in it,
etc. However, I want to filter data out before it comes in to Excel but
without using MS Project views, filters or maps.

Why without - because some of the people who will use this template don't
even know what a view is, never mind the fact they may change it and corrupt
the table that uses it. Whilst very sharp guys in other respects, I want to
make this macro and template as idiot proof as possible.

The part of the code for brining the fields in is below but I want to filter
out any Number1 values greater that 3 or blank.

varRowCount = 1

For Each varTask In varProj.Tasks
varTaskInformations.Offset(varRowCount, 0) = varTask.Text1
varTaskInformations.Offset(varRowCount, 1) = varTask.Text25
varTaskInformations.Offset(varRowCount, 2) = varTask.Number1
varTaskInformations.Offset(varRowCount, 3) = varTask.Name
varTaskInformations.Offset(varRowCount, 4) = varTask.PercentComplete
varTaskInformations.Offset(varRowCount, 5) = varTask.BaselineFinish
varTaskInformations.Offset(varRowCount, 6) = varTask.Finish
varTaskInformations.Offset(varRowCount, 7) = varTask.Date10
varTaskInformations.Offset(varRowCount, 8) = varTask.Text21
varTaskInformations.Offset(varRowCount, 9) = varTask.Text22
varTaskInformations.Offset(varRowCount, 10) = varTask.Text26
varTaskInformations.Offset(varRowCount, 11) = varTask.Text19
varTaskInformations.Offset(varRowCount, 12) = varTask.Flag20
varTaskInformations.Offset(varRowCount, 13) = varTask.Text23
varTaskInformations.Offset(varRowCount, 14) = varTask.Flag18
varTaskInformations.Offset(varRowCount, 15) = varTask.Flag19
varTaskInformations.Offset(varRowCount, 16) = varTask.Text10

Me.lblProgress.Width = 222 * (varRowCount / varProj.Tasks.Count)
Me.fmeProgress.Caption = Format(varRowCount / varProj.Tasks.Count, "0%")
DoEvents

varRowCount = varRowCount + 1
Next

Any help greatly appreciated as this is driving me nuts and now rather ugent.

Many thanks

Ian H
 
J

John

I have borrowed some code off the net (it was free by the way but can't find
the chap's name at present) that imports project data in to an excel template
I created that has conditional formatting and variable name ranges in it,
etc. However, I want to filter data out before it comes in to Excel but
without using MS Project views, filters or maps.

Why without - because some of the people who will use this template don't
even know what a view is, never mind the fact they may change it and corrupt
the table that uses it. Whilst very sharp guys in other respects, I want to
make this macro and template as idiot proof as possible.

The part of the code for brining the fields in is below but I want to filter
out any Number1 values greater that 3 or blank.

varRowCount = 1

For Each varTask In varProj.Tasks
varTaskInformations.Offset(varRowCount, 0) = varTask.Text1
varTaskInformations.Offset(varRowCount, 1) = varTask.Text25
varTaskInformations.Offset(varRowCount, 2) = varTask.Number1
varTaskInformations.Offset(varRowCount, 3) = varTask.Name
varTaskInformations.Offset(varRowCount, 4) = varTask.PercentComplete
varTaskInformations.Offset(varRowCount, 5) = varTask.BaselineFinish
varTaskInformations.Offset(varRowCount, 6) = varTask.Finish
varTaskInformations.Offset(varRowCount, 7) = varTask.Date10
varTaskInformations.Offset(varRowCount, 8) = varTask.Text21
varTaskInformations.Offset(varRowCount, 9) = varTask.Text22
varTaskInformations.Offset(varRowCount, 10) = varTask.Text26
varTaskInformations.Offset(varRowCount, 11) = varTask.Text19
varTaskInformations.Offset(varRowCount, 12) = varTask.Flag20
varTaskInformations.Offset(varRowCount, 13) = varTask.Text23
varTaskInformations.Offset(varRowCount, 14) = varTask.Flag18
varTaskInformations.Offset(varRowCount, 15) = varTask.Flag19
varTaskInformations.Offset(varRowCount, 16) = varTask.Text10

Me.lblProgress.Width = 222 * (varRowCount / varProj.Tasks.Count)
Me.fmeProgress.Caption = Format(varRowCount / varProj.Tasks.Count, "0%")
DoEvents

varRowCount = varRowCount + 1
Next

Any help greatly appreciated as this is driving me nuts and now rather ugent.

Many thanks

Ian H

Ian,
Try the following structure:

[apply your desired filter either manually or via the EditFilter VBA
Method]
SelectTaskColumn
For Each varTask in ActiveSelection.Tasks
[your stuff]
Next varTask

Hope this helps.

John
Project MVP
 
J

John

I have borrowed some code off the net (it was free by the way but can't find
the chap's name at present) that imports project data in to an excel template
I created that has conditional formatting and variable name ranges in it,
etc. However, I want to filter data out before it comes in to Excel but
without using MS Project views, filters or maps.

Why without - because some of the people who will use this template don't
even know what a view is, never mind the fact they may change it and corrupt
the table that uses it. Whilst very sharp guys in other respects, I want to
make this macro and template as idiot proof as possible.

The part of the code for brining the fields in is below but I want to filter
out any Number1 values greater that 3 or blank.

varRowCount = 1

For Each varTask In varProj.Tasks
varTaskInformations.Offset(varRowCount, 0) = varTask.Text1
varTaskInformations.Offset(varRowCount, 1) = varTask.Text25
varTaskInformations.Offset(varRowCount, 2) = varTask.Number1
varTaskInformations.Offset(varRowCount, 3) = varTask.Name
varTaskInformations.Offset(varRowCount, 4) = varTask.PercentComplete
varTaskInformations.Offset(varRowCount, 5) = varTask.BaselineFinish
varTaskInformations.Offset(varRowCount, 6) = varTask.Finish
varTaskInformations.Offset(varRowCount, 7) = varTask.Date10
varTaskInformations.Offset(varRowCount, 8) = varTask.Text21
varTaskInformations.Offset(varRowCount, 9) = varTask.Text22
varTaskInformations.Offset(varRowCount, 10) = varTask.Text26
varTaskInformations.Offset(varRowCount, 11) = varTask.Text19
varTaskInformations.Offset(varRowCount, 12) = varTask.Flag20
varTaskInformations.Offset(varRowCount, 13) = varTask.Text23
varTaskInformations.Offset(varRowCount, 14) = varTask.Flag18
varTaskInformations.Offset(varRowCount, 15) = varTask.Flag19
varTaskInformations.Offset(varRowCount, 16) = varTask.Text10

Me.lblProgress.Width = 222 * (varRowCount / varProj.Tasks.Count)
Me.fmeProgress.Caption = Format(varRowCount / varProj.Tasks.Count, "0%")
DoEvents

varRowCount = varRowCount + 1
Next

Any help greatly appreciated as this is driving me nuts and now rather ugent.

Many thanks

Ian H

Ian,
I need to add something to my original response. The only way to get
filtered data from Project is via a view. Filtered data cannot, as far
as I know, be pulled directly from Project's underlying database.

You mentioned that you do not want to depend on users setting up a
particular view to apply the filter. This is a common issue and any
macro worth its "salt" should be pretty much immune to what the user
does or does not do. To set things up for the macro transfer of data I
would include the following code ahead of what you already have, as
modified per my original response.

Dim oldview as String
oldview = ActiveProejct.CurrentView
TableEdit Name:="Ian tbl", TaskTable:=True, create:=True, _
overwriteexisting:=True, newfieldname:="Text1"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text25"
[continue TableEdit Method for remaining fields]

On Error Resume Next
ViewEditSingle Name:="Ian view", create:=True, Screen:=pjTaskSheet, _
Table:="Ian tbl", Filter:="All tasks", Group:="no group"
ViewApply Name:="Ian view"
On Error GoTo 0

[insert your existing code here]

ViewApply Name:=oldview
OrganizerDeleteItem Type:=pjViews, FileName:=activeproject.FullName, _
Name:="Ian view"
OrganizerDeleteItem Type:=pjTables, FileName:=activeproject.FullName, _
Name:="Ian tbl"
SelectBeginning

Some comments about the above code. This code first captures the user's
existing view and then creates and applies a custom view to be used by
the macro code. Once the macro is finished the custom view is deleted
and the original user's view is reinstated. You will note that the
custom view does not apply any particular filter. This leaves the option
open to apply any built-in or custom filter, which may also be created
in code using the FIlterEdit Method.

Hope this helps.
John
Project MVP
 
J

Jack Dahlgren MVP

Just a line of code like this:

if (varTask.Number1 > 0 and varTask.Number1 < 3) then
varTaskInformations.Offset(varRowCount, 2) = varTask.Number1

should do it.

You should note that there are no blanks in number columns. They are either
0 or some other number.

-Jack
 
I

Ian H - Project Swat

Many thanks for this John, looking at putting this in place tonight.

My problem wth views was people keep changing them, pity I can't protect
fields, views, etc.:)

Thanks again

Ian h

John said:
I have borrowed some code off the net (it was free by the way but can't find
the chap's name at present) that imports project data in to an excel template
I created that has conditional formatting and variable name ranges in it,
etc. However, I want to filter data out before it comes in to Excel but
without using MS Project views, filters or maps.

Why without - because some of the people who will use this template don't
even know what a view is, never mind the fact they may change it and corrupt
the table that uses it. Whilst very sharp guys in other respects, I want to
make this macro and template as idiot proof as possible.

The part of the code for brining the fields in is below but I want to filter
out any Number1 values greater that 3 or blank.

varRowCount = 1

For Each varTask In varProj.Tasks
varTaskInformations.Offset(varRowCount, 0) = varTask.Text1
varTaskInformations.Offset(varRowCount, 1) = varTask.Text25
varTaskInformations.Offset(varRowCount, 2) = varTask.Number1
varTaskInformations.Offset(varRowCount, 3) = varTask.Name
varTaskInformations.Offset(varRowCount, 4) = varTask.PercentComplete
varTaskInformations.Offset(varRowCount, 5) = varTask.BaselineFinish
varTaskInformations.Offset(varRowCount, 6) = varTask.Finish
varTaskInformations.Offset(varRowCount, 7) = varTask.Date10
varTaskInformations.Offset(varRowCount, 8) = varTask.Text21
varTaskInformations.Offset(varRowCount, 9) = varTask.Text22
varTaskInformations.Offset(varRowCount, 10) = varTask.Text26
varTaskInformations.Offset(varRowCount, 11) = varTask.Text19
varTaskInformations.Offset(varRowCount, 12) = varTask.Flag20
varTaskInformations.Offset(varRowCount, 13) = varTask.Text23
varTaskInformations.Offset(varRowCount, 14) = varTask.Flag18
varTaskInformations.Offset(varRowCount, 15) = varTask.Flag19
varTaskInformations.Offset(varRowCount, 16) = varTask.Text10

Me.lblProgress.Width = 222 * (varRowCount / varProj.Tasks.Count)
Me.fmeProgress.Caption = Format(varRowCount / varProj.Tasks.Count, "0%")
DoEvents

varRowCount = varRowCount + 1
Next

Any help greatly appreciated as this is driving me nuts and now rather ugent.

Many thanks

Ian H

Ian,
I need to add something to my original response. The only way to get
filtered data from Project is via a view. Filtered data cannot, as far
as I know, be pulled directly from Project's underlying database.

You mentioned that you do not want to depend on users setting up a
particular view to apply the filter. This is a common issue and any
macro worth its "salt" should be pretty much immune to what the user
does or does not do. To set things up for the macro transfer of data I
would include the following code ahead of what you already have, as
modified per my original response.

Dim oldview as String
oldview = ActiveProejct.CurrentView
TableEdit Name:="Ian tbl", TaskTable:=True, create:=True, _
overwriteexisting:=True, newfieldname:="Text1"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text25"
[continue TableEdit Method for remaining fields]

On Error Resume Next
ViewEditSingle Name:="Ian view", create:=True, Screen:=pjTaskSheet, _
Table:="Ian tbl", Filter:="All tasks", Group:="no group"
ViewApply Name:="Ian view"
On Error GoTo 0

[insert your existing code here]

ViewApply Name:=oldview
OrganizerDeleteItem Type:=pjViews, FileName:=activeproject.FullName, _
Name:="Ian view"
OrganizerDeleteItem Type:=pjTables, FileName:=activeproject.FullName, _
Name:="Ian tbl"
SelectBeginning

Some comments about the above code. This code first captures the user's
existing view and then creates and applies a custom view to be used by
the macro code. Once the macro is finished the custom view is deleted
and the original user's view is reinstated. You will note that the
custom view does not apply any particular filter. This leaves the option
open to apply any built-in or custom filter, which may also be created
in code using the FIlterEdit Method.

Hope this helps.
John
Project MVP
.
 
I

Ian H - Project Swat

A big helpJack thanks.

The company have numbered anything not a Level 0-3 mielstone as 666 (maybe
Black Sabbath fans) to get round the default 0. A bit messy but works

I am still a major novice at VBA guys and the worse thing is (or best), that
the more I learn the more potential uses I see and have to find more ways to
do it:)

My thanks again

Ian H
 
I

Ian H - Project Swat

Thought I got this but seems not as I'm not sure where I need to put this I'm
afraid.

I assumed it was to go at the front of all the other fields to be imported
and it would filter them but doesn't filter at all.

I should have mentioned that this is one of a couple of criteria in that
Text18 should only have 'IT Activity' in it.

Do I have to state the number one range 'then' criteria for every field I
wish to bring in to ensur it filters out the rest?

Many thanks

Ian h
 
J

John

Many thanks for this John, looking at putting this in place tonight.

My problem wth views was people keep changing them, pity I can't protect
fields, views, etc.:)

Thanks again

Ian h
Ian,
I responded to the first part of your post where you asked how to deal
with the users variation in views. Jack's response focused on the last
part of your post where you wanted to filter out the Number1 field.

Jack's approach does not apply a "filter" as you might normally think of
in Project. To do that in VBA you need the FIlterEdit Method as I
suggested. Jack's line of code is simply a variation of the third line
in your existing code that ignores any values in the Number1 field that
are positive but less than 3. It's a very simple and efficient way to
get, or ignore, specific data while in a loop.

With the more general approach I suggested you do in fact "protect" the
view you need to run the macro because it is specifically created each
time the code runs. I doesn't matter what view the user has or what the
user may have done to an existing view.

You don't mention how the Project file(s) are controlled, only that many
people have access. If you have problems or concerns about users
changing views or doing other things they should not be doing to the
file, then the first and best approach is user training. However,
regardless of how much training is given there will always be the
inevitable "oops" or perhaps some "nefarious activities" that will
occur. To recover from those type of things you should have a backup
file, (and it can be a blank project file), that contains the master set
of custom tables, views, filters, etc. When the inevitable occurs,
simply use the Organizer to reinstate the custom settings from the
"master" file.

You also mention that you are a novice to VBA but see the great
potential for using it. Fellow MVP, Rod Gill, has an excellent book on
the subject. For more information, go to, http://www.projectvbabook.com

John
Project MVP
John said:
I have borrowed some code off the net (it was free by the way but can't
find
the chap's name at present) that imports project data in to an excel
template
I created that has conditional formatting and variable name ranges in it,
etc. However, I want to filter data out before it comes in to Excel but
without using MS Project views, filters or maps.

Why without - because some of the people who will use this template don't
even know what a view is, never mind the fact they may change it and
corrupt
the table that uses it. Whilst very sharp guys in other respects, I want
to
make this macro and template as idiot proof as possible.

The part of the code for brining the fields in is below but I want to
filter
out any Number1 values greater that 3 or blank.

varRowCount = 1

For Each varTask In varProj.Tasks
varTaskInformations.Offset(varRowCount, 0) = varTask.Text1
varTaskInformations.Offset(varRowCount, 1) = varTask.Text25
varTaskInformations.Offset(varRowCount, 2) = varTask.Number1
varTaskInformations.Offset(varRowCount, 3) = varTask.Name
varTaskInformations.Offset(varRowCount, 4) = varTask.PercentComplete
varTaskInformations.Offset(varRowCount, 5) = varTask.BaselineFinish
varTaskInformations.Offset(varRowCount, 6) = varTask.Finish
varTaskInformations.Offset(varRowCount, 7) = varTask.Date10
varTaskInformations.Offset(varRowCount, 8) = varTask.Text21
varTaskInformations.Offset(varRowCount, 9) = varTask.Text22
varTaskInformations.Offset(varRowCount, 10) = varTask.Text26
varTaskInformations.Offset(varRowCount, 11) = varTask.Text19
varTaskInformations.Offset(varRowCount, 12) = varTask.Flag20
varTaskInformations.Offset(varRowCount, 13) = varTask.Text23
varTaskInformations.Offset(varRowCount, 14) = varTask.Flag18
varTaskInformations.Offset(varRowCount, 15) = varTask.Flag19
varTaskInformations.Offset(varRowCount, 16) = varTask.Text10

Me.lblProgress.Width = 222 * (varRowCount / varProj.Tasks.Count)
Me.fmeProgress.Caption = Format(varRowCount / varProj.Tasks.Count,
"0%")
DoEvents

varRowCount = varRowCount + 1
Next

Any help greatly appreciated as this is driving me nuts and now rather
ugent.

Many thanks

Ian H

Ian,
I need to add something to my original response. The only way to get
filtered data from Project is via a view. Filtered data cannot, as far
as I know, be pulled directly from Project's underlying database.

You mentioned that you do not want to depend on users setting up a
particular view to apply the filter. This is a common issue and any
macro worth its "salt" should be pretty much immune to what the user
does or does not do. To set things up for the macro transfer of data I
would include the following code ahead of what you already have, as
modified per my original response.

Dim oldview as String
oldview = ActiveProejct.CurrentView
TableEdit Name:="Ian tbl", TaskTable:=True, create:=True, _
overwriteexisting:=True, newfieldname:="Text1"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text25"
[continue TableEdit Method for remaining fields]

On Error Resume Next
ViewEditSingle Name:="Ian view", create:=True, Screen:=pjTaskSheet, _
Table:="Ian tbl", Filter:="All tasks", Group:="no group"
ViewApply Name:="Ian view"
On Error GoTo 0

[insert your existing code here]

ViewApply Name:=oldview
OrganizerDeleteItem Type:=pjViews, FileName:=activeproject.FullName, _
Name:="Ian view"
OrganizerDeleteItem Type:=pjTables, FileName:=activeproject.FullName, _
Name:="Ian tbl"
SelectBeginning

Some comments about the above code. This code first captures the user's
existing view and then creates and applies a custom view to be used by
the macro code. Once the macro is finished the custom view is deleted
and the original user's view is reinstated. You will note that the
custom view does not apply any particular filter. This leaves the option
open to apply any built-in or custom filter, which may also be created
in code using the FIlterEdit Method.

Hope this helps.
John
Project MVP
.
 
I

Ian H - Project Swat

Still can't get either approach to work unfortunately.

On yours John, it stops at a next statement furthr down my code, which
didn't stop before.

If I take that 'Next' out of the picture (not being VB savvy, I don't know
what that affected) then it runs further but stops at another bit of my code
which didn't stop before - being the

'varTaskInformations.Offset(varRowCount, 0) = varTask.Name'

....at the start of the import.

Any further help would be a godsend on either approach gents

New to this forum so apologies if not supposed to paste code in due to size,
etc. guys.


---------------------------------------------------

Option Explicit

Private Sub UserForm_Activate()

Dim varFileName As Variant
Dim varProjApp As MSProject.Application
Dim varProj As MSProject.Project
Dim varTask As MSProject.Task
Dim varTaskInformations As Range
Dim varRowCount As Integer

varFileName = Application.GetOpenFilename("Microsoft Project Files
(*.mpp), *.mpp")
If varFileName = False Then
Unload Me
Exit Sub
End If

' Worksheets("IT Milestones").Range("myProjectFileName") = varFileName

On Error Resume Next

Range("myProjectInfoRange").ClearContents

Set varProjApp = GetObject(, "MSProject.Application")

If varProjApp Is Nothing Then
Set varProjApp = New MSProject.Application

If varProjApp Is Nothing Then
MsgBox "Connection to Microsoft Project not possible"
End If

varProjApp.Visible = False
End If

varProjApp.FileOpen Name:=varFileName, OpenPool:=pjDoNotOpenPool
Set varProj = varProjApp.ActiveProject

varProjApp.ActivateMicrosoftApp pjMicrosoftExcel

Application.ScreenUpdating = True
Me.fmeProgress.Caption = "Importing Project Data...."

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Set varTaskInformations = Range("myStartProjTaskInfo")

'enter a line to clear content
Range("myProjectInfoRange").Select
Selection.ClearContents

'Code from jack MVP

'If (varTask.Number1 > 0 And varTask.Number1 < 3) Then
varTaskInformations.Offset(varRowCount, 2) = varTask.Number1

'Code from Jonh MVP to create view in MSP
Dim oldview As String
oldview = ActiveProject.CurrentView
TableEdit Name:="Ian tbl", TaskTable:=True, create:=True, _
overwriteexisting:=True, newfieldname:="Text1"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text25"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Number1"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Name"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="PercentComplete"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="BaselineFinish"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Finish"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Date10"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text21"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text22"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text26"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text19"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text23"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Flag19"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Flag18"
TableEdit Name:="Ian tbl", TaskTable:=True, newfieldname:="Text10"

On Error Resume Next
ViewEditSingle Name:="Ian view", create:=True, Screen:=pjTaskSheet, _
Table:="Ian tbl", Filter:="All tasks", Group:="no group"
ViewApply Name:="Ian view"
On Error GoTo 0

'[insert your existing code here]
varTaskInformations.Offset(varRowCount, 0) = varTask.Name
varTaskInformations.Offset(varRowCount, 4) = varTask.Text1
varTaskInformations.Offset(varRowCount, 8) = varTask.Text25
varTaskInformations.Offset(varRowCount, 5) = varTask.Number1
varTaskInformations.Offset(varRowCount, 5) = varTask.Name
varTaskInformations.Offset(varRowCount, 1) = varTask.PercentComplete
varTaskInformations.Offset(varRowCount, 27) = varTask.BaselineFinish
varTaskInformations.Offset(varRowCount, 3) = varTask.Finish
varTaskInformations.Offset(varRowCount, 16) = varTask.Date10
varTaskInformations.Offset(varRowCount, 11) = varTask.Text21
varTaskInformations.Offset(varRowCount, 11) = varTask.Text22
varTaskInformations.Offset(varRowCount, 12) = varTask.Text26
varTaskInformations.Offset(varRowCount, 21) = varTask.Text19
varTaskInformations.Offset(varRowCount, 14) = varTask.Text23
varTaskInformations.Offset(varRowCount, 16) = varTask.Flag19
varTaskInformations.Offset(varRowCount, 15) = varTask.Flag18
varTaskInformations.Offset(varRowCount, 24) = varTask.Text10

'Rest of code from John MVP

ViewApply Name:=oldview
OrganizerDeleteItem Type:=pjViews, Filename:=ActiveProject.FullName, _
Name:="Ian view"
OrganizerDeleteItem Type:=pjTables, Filename:=ActiveProject.FullName, _
Name:="Ian tbl"
SelectBeginning


Me.lblProgress.Width = 222 * (varRowCount / varProj.Tasks.Count)
Me.fmeProgress.Caption = Format(varRowCount / varProj.Tasks.Count, "0%")
DoEvents

varRowCount = varRowCount + 1
'Next

Me.fmeProgress.Caption = "Closing Microsoft Project and finalizing..."
DoEvents

varProjApp.FileClose pjDoNotSave

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

Set varProj = Nothing
Set varProjApp = Nothing
Unload Me

'Sub setprintarea() Ian Hush - this sets a variable print range
Dim myrange As String

myrange = Cells(Rows.Count, 11).End(xlUp).Address

ActiveSheet.PageSetup.PrintArea = "$A$1:" & myrange



End Sub
-------------------------------------------------------
Private Sub UserForm_Initialize()
With lblProgress
.Width = 0
.Left = lblBackGround.Left
.Top = lblBackGround.Top
End With
End Sub
 
Top