Fixing broken, invalid references

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I link to MS Project to gather data for my MS Acces database. I am
referencing the MS Project 11.0 Object Library from Access. The people that
are using the database have the MS Project 10.0 Object Library. How can I
resolve this at the application startup without user intervention?
 
TimD said:
I link to MS Project to gather data for my MS Acces database. I am
referencing the MS Project 11.0 Object Library from Access. The
people that are using the database have the MS Project 10.0 Object
Library. How can I resolve this at the application startup without
user intervention?

Use late binding which allows you to completely remove the reference and makes
the code (for the most part) version neutral. If you Google these groups for
"late binding" you will get lots of links.
 
OK, I have read lots on Late and Early binding. Most all refers to Word or
Excel. I do not see any MSProject specific syntax on late binding. The
examples I have tried all give me errors.
 
To use late binding, you need to do at least:

1) Replace all declarations of
Dim MyVariable As <Library>.<ObjectType>
with
Dim MyVariable As Object
2) Replace all decarations of
Set MyVariable = New <Library>.<ObjectType>
with
Set MyVariable = CreateObject("<Library>.<ObjectType>")
3) Determine any named constants that you're using from the referenced
library, and either replace the named constants with their value, or declare
the named constants in your own code.

The 3rd step is obviously the most time consuming change to make. Once you
remove the reference, you'll be able to find missing constants by doing a
compile, but you'll find them one at a time.

If you were using

Dim MyVariable As New <Library>.<ObjectType>

you'll need to change it to the 2 step approach above.

Post your existing code. We should be able to point out all of the changes
that are required.
 
Private Sub cmdUpdateProjectData_Click()

On Error GoTo cmdUpdateProjectData_Click_Error

Dim db As DAO.Database
Dim rsICSProjectImport As DAO.Recordset
Dim rsDocumentDetail As DAO.Recordset
Dim rsLUWDetail As DAO.Recordset
Dim prjActive As Project
Dim tskAny As Task
Dim strICSProjectImport As String
Dim strDocumentDetail As String
Dim strLUWDetail As String
Dim strOpenProject As String
Dim strTDSERROR As String
Dim strHLDERROR As String
Dim strSQL As String
Dim strTestIn As String
Dim intCount As Integer
Dim intTrackCount As Integer
Dim intStartLen As Integer
Dim intFinishLen As Integer
Dim intActualStartLen As Integer
Dim intActualFinishLen As Integer
Dim intIntialLoadFlag As Integer 'Load dates if this is set
Dim intValUserVars As Integer
Dim intDEBUGTHIS As Integer
Dim varLoadtime As Variant
Dim varHLDLoadTime As Variant
Dim varTDSLoadTime As Variant
Dim varDumpTime As Variant

DoCmd.SetWarnings True
StartTimer
intDEBUGTHIS = 0
intIntialLoadFlag = 0 'Load dates if this is set
lblProgressStatus.Caption = ""
lblProgressStatus2.Caption = ""
lblProgressStatus3.Caption = ""
pbrProgressStatus.Visible = False
cmdCancel.Visible = False
DoCmd.RepaintObject acForm, "frmProjectImport"

intValUserVars = ValidateUserVars

If intValUserVars Then
MsgBox "Please correct your user variables!"
cmdUpdateProjectData.Transparent = True
cmdCancel.Caption = "Exit"
cmdCancel.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
Exit Sub
End If

' Purge Project table
lblProgressStatus.Caption = "Removing old data"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"

strSQL = "DELETE tblICSProjectImport.UniqueID From tblICSProjectImport;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

varDumpTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "Dump Time = "; varDumpTime

lblProgressStatus.Caption = "Opening MS Project file " &
strContractorSchedule
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
strOpenProject = strMSProjectDirectory & "\" & strContractorSchedule
MSProject.Application.FileOpen Name:=strOpenProject
Set prjActive = MSProject.Application.ActiveProject
strICSProjectImport = "tblICSProjectImport"
strDocumentDetail = "tblDocumentDetail"
strLUWDetail = "tblLUWDetail"
intCount = 0
intTrackCount = 0
Set db = CurrentDb
Set rsICSProjectImport = db.OpenRecordset(strICSProjectImport,
dbOpenDynaset)
Set rsDocumentDetail = db.OpenRecordset(strDocumentDetail, dbOpenDynaset)
Set rsLUWDetail = db.OpenRecordset(strLUWDetail, dbOpenDynaset)

' Load Project data into tblICSProjectImport
lblProgressStatus.Caption = "Loading Project Data, please be patient!"
lblProgressStatus2.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
For Each tskAny In prjActive.Tasks
'Long loop removed
Next

FileExit pjDoNotSave
Dim i As Integer
Dim t As Integer
For i = 1 To 10
For t = 1 To 10000
Next
Next

varLoadtime = ElapsedTime
lblProgressStatus.Caption = "Load Time = " & varLoadtime
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
If intDEBUG > 1 Then Debug.Print "Load Time = "; varLoadtime

' Set the progress bar values
lblProgressStatus2.Visible = False
pbrProgressStatus.Visible = True
pbrProgressStatus.Min = 0
pbrProgressStatus.Max = rsICSProjectImport.RecordCount
pbrProgressStatus.Value = 0

' Find UniqueID in rsICSProjectImport and copy data into rsLUWDetail with
DocumentID
lblProgressStatus.Caption = "Loading TDS Data"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
intCount = 0
rsICSProjectImport.MoveFirst
Do Until rsICSProjectImport.EOF
With rsICSProjectImport
strTDSERROR = rsICSProjectImport!UniqueID
rsLUWDetail.MoveFirst
DoCmd.RepaintObject acForm, "frmProjectImport"
Do Until rsLUWDetail.EOF
If Not IsNull(rsLUWDetail!UniqueIDTDSDev) Then
If !UniqueID = Val(rsLUWDetail!UniqueIDTDSDev) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If IsNull(rsLUWDetail!TDSWBS) Then
rsLUWDetail.Edit
rsLUWDetail!TDSWBS = !WBS
rsLUWDetail.Update
End If
If intIntialLoadFlag Then
rsLUWDetail.Edit
rsLUWDetail!TDSDevStart = !Start
rsLUWDetail!TDSDevFinish = !Finish
rsLUWDetail!TDSDevActualStart = !ActualStart
rsLUWDetail!TDSDevActualFinish = !ActualFinish
rsLUWDetail.Update
End If
If IsNull(!Start) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevStart = False
rsLUWDetail.Update
Else
If CDate(!Start) = rsLUWDetail!TDSDevStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!Finish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevFinish = False
rsLUWDetail.Update
Else
If CDate(!Finish) = rsLUWDetail!TDSDevFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevFinish = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualStart = False
rsLUWDetail.Update
Else
If CDate(!ActualStart) =
rsLUWDetail!TDSDevActualStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualFinish = False
rsLUWDetail.Update
Else
If CDate(!ActualFinish) =
rsLUWDetail!TDSDevActualFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSDevActualFinish = False
rsLUWDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
If Not IsNull(rsLUWDetail!UniqueIDTDSObjDev) Then
If !UniqueID = Val(rsLUWDetail!UniqueIDTDSObjDev) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If intIntialLoadFlag Then
rsLUWDetail.Edit
rsLUWDetail!TDSObjDevStart = !Start
rsLUWDetail!TDSObjDevFinish = !Finish
rsLUWDetail!TDSObjDevActualStart = !ActualStart
rsLUWDetail!TDSObjDevActualFinish = !ActualFinish
rsLUWDetail.Update
End If
If IsNull(!Start) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevStart = False
rsLUWDetail.Update
Else
If CDate(!Start) = rsLUWDetail!TDSObjDevStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!Finish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevFinish = False
rsLUWDetail.Update
Else
If CDate(!Finish) = rsLUWDetail!TDSObjDevFinish
Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevFinish = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualStart = False
rsLUWDetail.Update
Else
If CDate(!ActualStart) =
rsLUWDetail!TDSObjDevActualStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualFinish = False
rsLUWDetail.Update
Else
If CDate(!ActualFinish) =
rsLUWDetail!TDSObjDevActualFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSObjDevActualFinish = False
rsLUWDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
If Not IsNull(rsLUWDetail!UniqueIDTDSCodeReview) Then
If !UniqueID = Val(rsLUWDetail!UniqueIDTDSCodeReview) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If intIntialLoadFlag Then
rsLUWDetail.Edit
rsLUWDetail!TDSCodeReviewStart = !Start
rsLUWDetail!TDSCodeReviewFinish = !Finish
rsLUWDetail!TDSCodeReviewActualStart =
!ActualStart
rsLUWDetail!TDSCodeReviewActualFinish =
!ActualFinish
rsLUWDetail.Update
End If
If IsNull(!Start) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewStart = False
rsLUWDetail.Update
Else
If CDate(!Start) =
rsLUWDetail!TDSCodeReviewStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewStart = False
rsLUWDetail.Update
End If
End If
If IsNull(!Finish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewFinish = False
rsLUWDetail.Update
Else
If CDate(!Finish) =
rsLUWDetail!TDSCodeReviewFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewFinish = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewFinish = False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualStart = False
rsLUWDetail.Update
Else
If CDate(!ActualStart) =
rsLUWDetail!TDSCodeReviewActualStart Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualStart = True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualStart =
False
rsLUWDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualFinish = False
rsLUWDetail.Update
Else
If CDate(!ActualFinish) =
rsLUWDetail!TDSCodeReviewActualFinish Then
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualFinish =
True
rsLUWDetail.Update
Else
rsLUWDetail.Edit
rsLUWDetail!ChkTDSCodeReviewActualFinish =
False
rsLUWDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
rsLUWDetail.MoveNext
Loop
pbrProgressStatus.Value = pbrProgressStatus.Value + 1
lblProgressStatus.Caption = "TDS fields updated " &
intTrackCount & " - Elapsed time " & ElapsedTime & " - Project Records read "
& intCount
lblProgressStatus3.Caption = Int(pbrProgressStatus.Value * 100 / _
pbrProgressStatus.Max) & "%"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
.MoveNext
intCount = intCount + 1
End With
Loop
varTDSLoadTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "TDS Time = "; varTDSLoadTime

' Find UniqueID in rsICSProjectImport and copy data into rsDocumentDetail
with DocumentID
pbrProgressStatus.Value = 0
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
intTrackCount = 0
intCount = 0
rsICSProjectImport.MoveFirst
Do Until rsICSProjectImport.EOF
With rsICSProjectImport
strHLDERROR = rsICSProjectImport!UniqueID
rsDocumentDetail.MoveFirst
DoCmd.RepaintObject acForm, "frmProjectImport"
Do Until rsDocumentDetail.EOF
If Not IsNull(rsDocumentDetail!UniqueIDHLDDev) Then
If !UniqueID = Val(rsDocumentDetail!UniqueIDHLDDev) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If IsNull(rsDocumentDetail!HLDWBS) Then
rsDocumentDetail.Edit
rsDocumentDetail!HLDWBS = !WBS
rsDocumentDetail.Update
End If
If intIntialLoadFlag Then
rsDocumentDetail.Edit
rsDocumentDetail!HLDDevStart = !Start
rsDocumentDetail!HLDDevFinish = !Finish
rsDocumentDetail!HLDDevActualStart = !ActualStart
rsDocumentDetail!HLDDevActualFinish =
!ActualFinish
rsDocumentDetail.Update
End If
If IsNull(!Start) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevStart = False
rsDocumentDetail.Update
Else
If CDate(!Start) = rsDocumentDetail!HLDDevStart
Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevStart = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevStart = False
rsDocumentDetail.Update
End If
End If
If IsNull(!Finish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevFinish = False
rsDocumentDetail.Update
Else
If CDate(!Finish) =
rsDocumentDetail!HLDDevFinish Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevFinish = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevFinish = False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualStart = False
rsDocumentDetail.Update
Else
If CDate(!ActualStart) =
rsDocumentDetail!HLDDevActualStart Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualStart = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualStart = False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualFinish = False
rsDocumentDetail.Update
Else
If CDate(!ActualFinish) =
rsDocumentDetail!HLDDevActualFinish Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualFinish = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDDevActualFinish = False
rsDocumentDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
If Not IsNull(rsDocumentDetail!UniqueIDHLDReviewApprove) Then
If !UniqueID =
Val(rsDocumentDetail!UniqueIDHLDReviewApprove) Then
' !UniqueID, !Release, !Name, !UniqueIDSuccessors,
!UniqueIDPredecessors, !Milestone, !OutlineLevel, !OutlineNumber,
!OutlineParent
If intIntialLoadFlag Then
rsDocumentDetail.Edit
rsDocumentDetail!HLDReviewApproveStart = !Start
rsDocumentDetail!HLDReviewApproveFinish = !Finish
rsDocumentDetail!HLDReviewApproveActualStart =
!ActualStart
rsDocumentDetail!HLDReviewApproveActualFinish =
!ActualFinish
rsDocumentDetail.Update
End If
If IsNull(!Start) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveStart = False
rsDocumentDetail.Update
Else
If CDate(!Start) =
rsDocumentDetail!HLDReviewApproveStart Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveStart =
True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveStart =
False
rsDocumentDetail.Update
End If
End If
If IsNull(!Finish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveFinish = False
rsDocumentDetail.Update
Else
If CDate(!Finish) =
rsDocumentDetail!HLDReviewApproveFinish Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveFinish =
True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveFinish =
False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualStart) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualStart
= False
rsDocumentDetail.Update
Else
If CDate(!ActualStart) =
rsDocumentDetail!HLDReviewApproveActualStart Then
rsDocumentDetail.Edit

rsDocumentDetail!ChkHLDReviewApproveActualStart = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit

rsDocumentDetail!ChkHLDReviewApproveActualStart = False
rsDocumentDetail.Update
End If
End If
If IsNull(!ActualFinish) Then
rsDocumentDetail.Edit
rsDocumentDetail!ChkHLDReviewApproveActualFinish
= False
rsDocumentDetail.Update
Else
If CDate(!ActualFinish) =
rsDocumentDetail!HLDReviewApproveActualFinish Then
rsDocumentDetail.Edit

rsDocumentDetail!ChkHLDReviewApproveActualFinish = True
rsDocumentDetail.Update
Else
rsDocumentDetail.Edit

rsDocumentDetail!ChkHLDReviewApproveActualFinish = False
rsDocumentDetail.Update
End If
End If
intTrackCount = intTrackCount + 1
End If
End If
rsDocumentDetail.MoveNext
Loop
intCount = intCount + 1
pbrProgressStatus.Value = pbrProgressStatus.Value + 1
lblProgressStatus.Caption = "HLD fields updated " &
intTrackCount & " - Elapsed time " & ElapsedTime & " - Project Records read "
& intCount
lblProgressStatus3.Caption = Int(pbrProgressStatus.Value * 100 / _
pbrProgressStatus.Max) & "%"
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
.MoveNext
End With
Loop
varHLDLoadTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "HLD Time = "; varHLDLoadTime

strSQL = "DELETE tblICSProjectImport.UniqueID From tblICSProjectImport;"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
varDumpTime = ElapsedTime
If intDEBUG > 1 Then Debug.Print "Dump Time = "; varDumpTime

lblProgressStatus.Caption = "Loading Data complete, Time " & varDumpTime
pbrProgressStatus.Visible = False
cmdCancel.Caption = "Exit"
cmdCancel.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"

rsICSProjectImport.Close
rsDocumentDetail.Close
rsLUWDetail.Close
Set rsICSProjectImport = Nothing
Set rsDocumentDetail = Nothing
Set rsLUWDetail = Nothing
Set db = Nothing

' Write time stamp to the database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("usystblUserVariables", dbOpenDynaset)
Do Until rs.EOF
With rs
If rs.Fields(1).Value = "strDateLastProjectUpdate" Then
rs.Edit
rs.Fields(2).Value = CStr(Now)
rs.Update
Exit Do
End If
.MoveNext
End With
Loop
rs.Close
Set rs = Nothing
Set db = Nothing

StopTimer

If intDEBUG > 1 Then Debug.Print "Total Time = "; ElapsedTime

On Error GoTo 0
Exit Sub

cmdUpdateProjectData_Click_Error:

DoCmd.SetWarnings True
MsgBox "TDS:" & strTDSERROR & vbCrLf & _
"HLD:" & strHLDERROR & vbCrLf & _
"Error " & Err.Number & " (" & Err.Description & ") in procedure
ImportProjectData of Module modImportProjectData" _
& vbCrLf & "Debug " & intDEBUGTHIS
cmdCancel.Caption = "Exit"
cmdCancel.Visible = True
Me.Repaint
DoCmd.RepaintObject acForm, "frmProjectImport"
rsICSProjectImport.Close
rsDocumentDetail.Close
rsLUWDetail.Close
Set rsICSProjectImport = Nothing
Set rsDocumentDetail = Nothing
Set rsLUWDetail = Nothing
Set db = Nothing
StopTimer

End Sub
 
You need to change

Dim prjActive As Project
Dim tskAny As Task

to

Dim prjActive As Object
Dim tskAny As Object

Add

Dim objProject As Object

I don't believe the line of code

MSProject.Application.FileOpen Name:=strOpenProject

is required (In fact, I don't believe it's valid in that context)

Change

Set prjActive = MSProject.Application.ActiveProject

to

Set objProject = CreateObject("MSProject.Application")
objProject.FileOpen Name:= strOpenProject
Set prjActive = objProject.ActiveProject

I have no idea why

FileExit pjDoNotSave

would be working for you now. I would expect it should be

objProject.FileExit <some value>

Unfortunately, I don't have Project installed on this machine, so I can't
check what the value for pjDoNotSave is. Before you remove the reference to
Project from your application, go to the Immediate Window (Ctrl-G), type

?pjDoNotSave

and hit Enter. Assuming it comes back as, say, 0, you can either do:

objProject.FileExit 0

or you can create a module where you'll store your declarations for Project
constants, and put

Public Const pjDoNotSave As Long = 0

in that module.

Any other changes you might require would be in

For Each tskAny In prjActive.Tasks
'Long loop removed
Next

but since you didn't give any details there, I can't help you.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


news:[email protected]...
 
Back
Top