Applescript – MS Excel to Merlin

Can I import a selected range of cell from an MS EXCEL sheet into Merlin as tasks?

Merlin can import various file formats.  For a complete list please check related topic in Merlin online help.

The official way to import MS EXCEL documents is to save them as csv files, and to open the csv file in Merlin in a second step.

  • So you select in MS EXCEL File > Save as… > Comma Separated Values (.csv)
  • You drag the csv text file to Merlin’s project listing and
  • map the fields of the csv files to Merlin columns.
  • Merlin will then import the file into the existing project.

To quicken things however, we have created a small Applescript sample, which handles the current MS EXCEL selection, goes through its rows and enters them as tasks into an existing Merlin project.

If interested, feel free to download, use or modify as you like. 

(* 	Scripting with Merlin 2

	You may incorporate this ProjectWizards sample code into your program(s) without
	restriction.  This ProjectWizards sample code has been provided "AS IS" and the
	responsibility for its operation is yours.  You are not permitted to
	redistribute this ProjectWizards sample code as "ProjectWizards sample code" after having
	made changes.  If you're going to redistribute the code, we require
	that you make it clear that the code was descended from ProjectWizards sample
	code, but that you've made changes.

	Copyright ® 2012 ProjectWizards, Melle, Germany. All rights reserved.

	This script goes through selected cells of MS EXCEL sheets,
	and inserts them as tasks in existing Merlin projects.  

        To use it, select the range you want to transfer to Merlin and start this script. 

	Important: 	- The script expects to find the date in the rows in the following order:
			Title | Work | Start date
			- Work entries may have units like d, w, week, year, y, etc.
			If they are empty the script assumes you need them in days
			- Start date will be transferred, only if it really is a date value

	Version info: 1.0
	Author: Vicky Stamatopoulou
	Date: October 2012

*)
----
property NeedAProjectMessage : "You must have an open Merlin project in order to run this script"
tell application "Microsoft Excel"
	-- read information from Excel
	set inList to {}
	set colStart to (get first column index of selection)
	set rowStart to (get first row index of selection)
	set colCount to (get count columns of selection)
	set rowCount to (get count rows of selection)

	repeat with i from rowStart to rowStart + rowCount - 1
		set inList to {}
		repeat with j from colStart to colStart + colCount - 1
			set TheValue to (value of cell j of row i)
			set inList to inList & (TheValue as list)
		end repeat
		set inList to addTaskInMerlin(inList) of me
	end repeat

end tell

on addTaskInMerlin(ListOfProperties)
	tell application "Merlin"

		try
			set doc to the first document
		on error
			display dialog NeedAProjectMessage
			set chosenFile to (choose file)
			open chosenFile
			set doc to the first document
		end try

		set proj to root project of doc

		set TheNewOne to (make new activity) as specifier
		tell TheNewOne
			set title to (item 1 of ListOfProperties) as text
			try
				get (item 2 of ListOfProperties) as number
				set given planned work to ((item 2 of ListOfProperties) as text) & "d"
			on error
				set given planned work to (item 2 of ListOfProperties)
			end try
			try
				get item 3 of ListOfProperties as date
				set given planned start date min to item 3 of ListOfProperties
			on error
				-- do not enter start date if this is not a date
			end try
		end tell
		move TheNewOne to the end of every activity of proj
		set ListOfProperties to {}
		return ListOfProperties
	end tell
end addTaskInMerlin

Download: GetMSEXCELLines.scpt.zip

 

 

9 thoughts on “Applescript – MS Excel to Merlin

  1. I can create and save user defined fields, but they are not available for an import (from excel). How can I either make them available for import, or copy the column imported to the new column?

  2. Hi Julie,

    and thank you for your comment.
    User defined fields are neither available by csv import, nor by Applescript, sorry.

    What about using the fields ‘additional title’, ‘sub title’ or ‘notes’ instead?
    Best regards, Vicky

  3. Hi,

    I would like to update a field (remaining budget) from Excel to an existing multi project file of Merlin on a timely (weekly) basis (manually). How can I update project fields in Merlin with project related infos from Excel (the key field is the project number which is unique in both programs.

    Regards
    Claus

  4. Hi Vicky,

    Thanks for this helpful script.

    I would like to import predecessor activities from Excel as well but am having trouble.

    The ‘next activities order string’ property is ro. Should I use relate start of and relate finish of commands?

    Any tips would be appreciated!

    Thanks,

    Amanda

  5. Hi Amanda,

    yes, you cannot just enter an activity number. You need a handle of predecessor activity, a handle of the successor activity and then relate the two activities. Following links two new activities and returns a handle of the linkage:
    tell application “Merlin”
    activate
    set one to make new activity
    set title of one to “predeccessor”

    set two to make new activity
    set title of two to “successor”

    set TheRelation to relate one to two

    end tell

    So when you create an activity by a make new activity… you need to save its handle in a variable to be able to use it later when linking to it.

    Best regards, Vicky

  6. Hi Vicky,

    When you User defined fields are neither available by csv import, nor by Applescript – do you mean from anywhere or just in the script?

    Kind regards,
    George

  7. User defined fields will be imported if defined in MS Project XML files you import into Merlin.

    Best regards, Vicky

  8. Nice excel tips. Are you experiencing youtube channel just for this tutorial? For those who have video tutorial, it is good mate 🙂

Comments are closed.