Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following script language code shown below within a main code just to run the tool of spatial analyst "Extract by mask". Unfortunately, when I run it I get a Run Time Error. I checked file names etc. but I cannot find the problem. Could anybody help me please?

Dim GP As Object
Set GP = CreateObject("esriGeoprocessing.GpDispatch.1")
GP.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst  Tools.tbx"
InRaster = "C:\LACONISS\LandSpaCES\valuationmapr"
InMask = "C:\LACONISS\LandSpaCES\Parcel165"
OutRaster = "C:\LACONISS\LandSpaCES\ParcelR165"
GP.CheckOutExtension ("Spatial")
GP.ExtractByMask_sa InRaster, InMask, OutRaster
share|improve this question
Does your code exist in VBA? If not, I do not think you can use Set in Also, looks like you have an extra space between Spatial Analyst and Tools.tbx. – artwork21 Dec 15 '11 at 15:56
Yes the code is in VBA. The extra space is just a typing error above. – Demetris Dec 15 '11 at 16:16
Does your ExtractByMask_sa need to have parenthesis around its parameters? Do you know the specific line that is raising the error? If you want the correct format you could just setup this tool in Model Builder than export it out to VBS. – artwork21 Dec 16 '11 at 1:49
Thanks for the effort.I found the problem. The syntax is correct. The problem is that one of the files was empty. – Demetris Dec 16 '11 at 19:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.