I've been having a play with the function posted here by ajetrumpet and have run into trouble with the line of code; Dim xl As New Excel.Application I'm getting a Compile error "User-defined type not defined" What should that line read?