Run-time error 1004

J

jeremy

Can someone see what I am obviously missing?

I am trying to write a maco to automate the merge of a csv file into a
resource pool file. I am getting the above error code and the
following explanation:

"The MergeKey argument is required when merging has been specified as
the input method."

I thought I had done that but the debug points me to the first MapEdit
line as the problem area. The coding is as follows:

Sub ImportCosts()
' Macro ImportCosts
' 29/08/2008 by Jeremy Crompton.
MapEdit Name:="Map 5", Create:=True, OverwriteExisting:=True,
DataCategory:=1, CategoryEnabled:=True, TableName:="BSI_Resource",
FieldName:="ID", ExternalFieldName:="ID", ExportFilter:="All
Resources", ImportMethod:=pjImportMerge, HeaderRow:=True,
AssignmentData:=False, TextDelimiter:=",", TextFileOrigin:=0,
UseHtmlTemplate:=False, IncludeImage:=False
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Unique ID",
ExternalFieldName:="Unique_ID", MergeKey:="Unique ID"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Name",
ExternalFieldName:="Resource_Name"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Initials",
ExternalFieldName:="Initials"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Max Units",
ExternalFieldName:="Max_Units"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Standard
Rate", ExternalFieldName:="Standard_Rate"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Overtime
Rate", ExternalFieldName:="Overtime_Rate"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Cost Per Use",
ExternalFieldName:="Cost_Per_Use"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Accrue At",
ExternalFieldName:="Accrue_At"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Cost",
ExternalFieldName:="Cost"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Baseline
Cost", ExternalFieldName:="Baseline_Cost"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Actual Cost",
ExternalFieldName:="Actual_Cost"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Work",
ExternalFieldName:="Scheduled_Work"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Baseline
Work", ExternalFieldName:="Baseline_Work"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Actual Work",
ExternalFieldName:="Actual_Work"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Overtime
Work", ExternalFieldName:="Overtime_Work"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Group",
ExternalFieldName:="Group_Name"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Code",
ExternalFieldName:="Code"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Text1",
ExternalFieldName:="Text1"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Text2",
ExternalFieldName:="Text2"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Text3",
ExternalFieldName:="Text3"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Text4",
ExternalFieldName:="Text4"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Text5",
ExternalFieldName:="Text5"
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Email
Address", ExternalFieldName:="Email_Address"
FileOpen Name:="\\cam249df\m117917$\Private\BSI\Project Planning
\Resources\BSI_Resource_Costs.csv", ReadOnly:=False, Merge:=1,
FormatID:="MSProject.CSV", map:="Map 5"
End Sub


I am using MS Project Pro 2003

Thanks in advance
 
J

John

Can someone see what I am obviously missing?

I am trying to write a maco to automate the merge of a csv file into a
resource pool file. I am getting the above error code and the
following explanation:

"The MergeKey argument is required when merging has been specified as
the input method."

I thought I had done that but the debug points me to the first MapEdit
line as the problem area. The coding is as follows:

Sub ImportCosts()
' Macro ImportCosts
' 29/08/2008 by Jeremy Crompton.
MapEdit Name:="Map 5", Create:=True, OverwriteExisting:=True,
DataCategory:=1, CategoryEnabled:=True, TableName:="BSI_Resource",
FieldName:="ID", ExternalFieldName:="ID", ExportFilter:="All
Resources", ImportMethod:=pjImportMerge, HeaderRow:=True,
AssignmentData:=False, TextDelimiter:=",", TextFileOrigin:=0,
UseHtmlTemplate:=False, IncludeImage:=False
MapEdit Name:="Map 5", DataCategory:=1, FieldName:="Unique ID",
ExternalFieldName:="Unique_ID", MergeKey:="Unique ID"
. . . .

Jeremy,
OK, you are obviously missing the MergeKey argument in the first MapEdit
statement - just like the error message says. The MergeKey argument is
present in the second MapEdit statement, but not in the first.

Don't feel bad, sometimes the simplest errors are a real bear to spot.
Been there, done that.

John
Project MVP
 
J

JayCee

Jeremy,
OK, you are obviously missing the MergeKey argument in the first MapEdit
statement - just like the error message says. The MergeKey argument is
present in the second MapEdit statement, but not in the first.

John

Thanks for that. Yup it seems straight forward - until I actually try
to edit the line to read as follows:

MapEdit Name:="Map 5", Create:=True, OverwriteExisting:=True,
DataCategory:=1, CategoryEnabled:=True,
TableName:="Resource_Export_Table", FieldName:="ID",
ExternalFieldName:="ID", ExportFilter:="All Resources",
ImportMethod:=2, MergeKey:="Unique ID", HeaderRow:=True,
AssignmentData:=False, TextDelimiter:=",", TextFileOrigin:=0,
UseHtmlTemplate:=False, IncludeImage:=False

I now get "Run-time error 1101 The argument is not valid"

Which is strange as it is a direct copy from the line below and, as
far as I can see, using the right syntax.

Have I run into a Microsoft feature? I'm off to try this in Project
2007 on another machine.......
 
J

JulieS

"JayCee" wrote in message
John

Thanks for that. Yup it seems straight forward - until I actually
try
to edit the line to read as follows:

MapEdit Name:="Map 5", Create:=True, OverwriteExisting:=True,
DataCategory:=1, CategoryEnabled:=True,
TableName:="Resource_Export_Table", FieldName:="ID",
ExternalFieldName:="ID", ExportFilter:="All Resources",
ImportMethod:=2, MergeKey:="Unique ID", HeaderRow:=True,
AssignmentData:=False, TextDelimiter:=",", TextFileOrigin:=0,
UseHtmlTemplate:=False, IncludeImage:=False

I now get "Run-time error 1101 The argument is not valid"

Which is strange as it is a direct copy from the line below and,
as
far as I can see, using the right syntax.

Have I run into a Microsoft feature? I'm off to try this in
Project
2007 on another machine.......

Hi Jeremy,

Pardon me for bumping in and I may be far off base here. You are
using the Unique ID as the merge key, but don't appear to be using
the Unique ID in list of fields you are working with. Try setting
the merge key to ID or make sure you are importing/exporting the
unique id as well.

Julie
 
J

John

JayCee said:
John

Thanks for that. Yup it seems straight forward - until I actually try
to edit the line to read as follows:

MapEdit Name:="Map 5", Create:=True, OverwriteExisting:=True,
DataCategory:=1, CategoryEnabled:=True,
TableName:="Resource_Export_Table", FieldName:="ID",
ExternalFieldName:="ID", ExportFilter:="All Resources",
ImportMethod:=2, MergeKey:="Unique ID", HeaderRow:=True,
AssignmentData:=False, TextDelimiter:=",", TextFileOrigin:=0,
UseHtmlTemplate:=False, IncludeImage:=False

I now get "Run-time error 1101 The argument is not valid"

Which is strange as it is a direct copy from the line below and, as
far as I can see, using the right syntax.

Have I run into a Microsoft feature? I'm off to try this in Project
2007 on another machine.......

Jeremy,
OK, the quick answer wasn't quite enough. Unfortunately I don't have
time right now to look into the issue further. If someone else spots the
problem, then great - if not, I'll take a look at it this evening.

John
Project MVP
 
J

John

JayCee said:
John

Thanks for that. Yup it seems straight forward - until I actually try
to edit the line to read as follows:

MapEdit Name:="Map 5", Create:=True, OverwriteExisting:=True,
DataCategory:=1, CategoryEnabled:=True,
TableName:="Resource_Export_Table", FieldName:="ID",
ExternalFieldName:="ID", ExportFilter:="All Resources",
ImportMethod:=2, MergeKey:="Unique ID", HeaderRow:=True,
AssignmentData:=False, TextDelimiter:=",", TextFileOrigin:=0,
UseHtmlTemplate:=False, IncludeImage:=False

I now get "Run-time error 1101 The argument is not valid"

Which is strange as it is a direct copy from the line below and, as
far as I can see, using the right syntax.

Have I run into a Microsoft feature? I'm off to try this in Project
2007 on another machine.......

Jeremy,
I didn't do extensive testing but after some quick tests and a little
analysis, my guess is that the Unique ID field cannot be used as a merge
key. Why? Because Project assigns the Unique ID number and attempting to
use it as a merge key would create a conflict between the existing
unique ID and the incoming data.

As Julie suggested, try using the ID field or use a spare field to
emulate the unique ID number and see if that helps.

Sorry I can't give a more definitive explanation. If I had more time, I
could research it more completely.

John
Project MVP
 
J

JayCee

As Julie suggested, try using the ID field or use a spare field to
emulate the unique ID number and see if that helps.

Sorry I can't give a more definitive explanation. If I had more time, I
could research it more completely.

John
Project MVP- Hide quoted text -

- Show quoted text -

Eureka! Thank you both for being so patient. Interestingly if I use
the record macro function and step through the process with the menus
I end up with the same errors. Go figure!!
Jeremy
 
J

John

JayCee said:
Eureka! Thank you both for being so patient. Interestingly if I use
the record macro function and step through the process with the menus
I end up with the same errors. Go figure!!
Jeremy

Jeremy,
You're welcome but I don't quite understand why that is a Eureka!

John
Project MVP
 

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