paste values only in excel

I have a NOOB question. I want to copy a range of cells and then Paste Special with values only to a different area of the same worksheet. Here is how I attempted to accomplish this without success:


tell application "Microsoft Excel"
	copy range range "B5:E258"
	goto reference "I5"
	paste special paste values
	
end tell

I am new to this stuff so I know I am missing something. Any help with this problem is greatly appreciated.

Hi s0569k,

Scripting the Microsoft Office products can be tricky. Maybe the following sample code will work for you?


tell application "Microsoft Excel"
	tell worksheet 1 of active workbook
		copy range (range "B5:E258")
		paste special (range "I5") what paste values
	end tell
end tell

Here is a good online resource about how to copy & paste values in Microsoft Excel:

AppleScript for MS Excel - Copy, paste, and paste special

This works perfect. Thank you so much. This puts me on the right track. Our office has a excel workbook we use for payroll that has quite a few macros in it that we have been using for several years. Now that Office will no longer support VBA. I am trying to convert our worksheet macros over to Applescript so we will be ready. I can see that this forum will be a great resource. Thanks again Martin.

-Scott

Hi s0569k,

If you want to convert Macros to AppleScript, then you should also take a look at this great free article:

Mactech - VBA to AppleScript Transition Guide

Moreover Microsoft also offers some great resources for learning purposes:

Office 2008 Mac Developers

Thanks again. These are great links. I have them bookmarked and I am reading over the MacTech one now.

Dead link, would like to see it. I have the Excel2004ApleSCriptRef document already though.