Error generated while opening a file from VBA

R

Rajesh R

Hi
I have written some VBA code, in MSP 2002, to detect if a
certain mpp file is open or not , if it is not open then
open it.

In VBA i am using the FileOpen command


<code>

Sub OpenTemplate()
On Error GoTo l_Errorhandler
Dim l_str_TemplateName As String
Dim l_int_ProjCnt As Integer
Dim l_tmp_TemplateName As String
Dim l_bol_ProjLoaded As Boolean


l_str_TemplateName = GetTemplateName()
If Not (l_bol_ProjLoaded) Then
l_str_TemplateName = l_str_TemplateName & ".mpp"
FileOpen l_str_TemplateName, True, , , , ,
True, "administrator", "0304admin65", "MSProject.mpp.9", ,
pjPoolReadWrite, , , False
FileOpen l_str_TemplateName
End If

l_Exit:
Exit Sub

l_Errorhandler:
Call gs_void_ErrorHandler(Err.Description, Err.Number,
Err.Source)
GoTo l_Exit
End Sub

</code>

l_str_TemplateName is the template name , now to this i
add the server url or even i tried considering the Full
Name!
But Microsoft Project 2002 throws up an error
****
Microsoft Project : 1004 : Microsoft Project cannot open
the file.
****


Please help me resolve this error !

Rgds Rajesh
 
R

Richard

Rajesh R said:
Dim l_str_TemplateName As String
Dim l_tmp_TemplateName As String
Dim l_bol_ProjLoaded As Boolean

l_str_TemplateName = GetTemplateName()
If Not (l_bol_ProjLoaded) Then
l_str_TemplateName = l_str_TemplateName & ".mpp"
FileOpen l_str_TemplateName, True, , , , ,
True, "administrator", "0304admin65", "MSProject.mpp.9", ,
pjPoolReadWrite, , , False
FileOpen l_str_TemplateName
End If
Rajesh,
The code for GetTemplateName() is not shown and could be the source of the
problem. The error might be in your variables. For example you have used
l_bol_ProjLoaded in the first if then else statement but it is not assinged a
value in the code shown. If you are trying to assign it a value in the sub
GetTemplateName then are you sure that you are refering to the same variable
(same name different scope).
I suggest that you step through the code and check the values of variables
before executing each line.
Cheers
Richard
 

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