0
votes

I am trying to import an excel file (office 2010) to microsoft project. When I do this manually it works fine (to confirm that the excel file is not corrupt). However, when I import it using macros (on launch of the MPP file) in MS Project, I get an error "Runtime error '1004'. Below is the code that I tried to execute from the MSProject.

Private Sub Project_Open(ByVal pj As Project)

    Dim strFilepath As String
    'strFilepath = "C:\Temp\ExcelSrc.xlsx"
    FileOpenEx Name:=strFilepath, ReadOnly:=False, Merge:=0, FormatID:="MSProject.ACE.14", map:="ExistingMap-ExcelSrc"
End Sub

I tried google but I found solutions related to excel VBA runtime error '1004' but not related to MS Project runtime error'1004'

Any help is greatly appreciated...Thanks in advance!, Ajx

1

1 Answers

0
votes

Here are a couple of things that stand out:

  • Don't open another file within the project open event. Put this code somewhere else.
  • Uncomment the file name variable initialization.
  • To merge an Excel file into the active Project file, the Merge parameter should be 1
  • Try using FormatID:="MSProject.xls"

If all that fails, record a macro using the steps that worked for you manually.