nmoylan

HOW DO I EXECUTE MY SCRIPT FROM WITHIN VBA?

Discussion created by nmoylan on Jun 16, 2010
Hi folks,
I've been trying to execute a python script from within VBA and can't figure out how to get around this error:

Error 000714: Error in Script IDTag

Here is the VBA code:

Option Explicit
Private m_pEditor As IEditor
Private WithEvents EditEvents As Editor

Private Sub startlistener_Click()

StartListeningToEditEvents

End Sub

Public Sub StartListeningToEditEvents()

Set EditEvents = Application.FindExtensionByName("ESRI Object Editor")

End Sub

Private Sub EditEvents_OnSketchFinished()

RunScript

MsgBox "TheEdit Sketch has been completed!"
'MsgBox to test if sub ran

End Sub
Public Sub RunScript()

Dim pGP As Object
Set pGP = CreateObject("esriGeoprocessing.GPDispatch.1")

On Error GoTo EH
pGP.AddToolbox ("F:\School\Semester3\GIS4309\_Test.tbx")

pGP.IDTag

Exit Sub

EH:

MsgBox pGP.GetMessages(), vbOKOnly, "Test"

End Sub

And Here is my Python Script:

import arcgisscripting
import time
gp = arcgisscripting.create(9.3)

localtime = time.asctime( time.localtime(time.time()) )

gp.workspace = "F:/School/Semester3/GIS4309"

rows = gp.searchcursor("SwanLakeProjected.shp", "", "", "FID", "FID" + " D")

row = rows.Next()
idTag = row.GetValue("FID")

del row
del rows

file = open("F:/School/Semester3/GIS4309/my_id_tags.txt", "r")

filedata = file.read()
file.close()

newLine = str(idTag) + "\t \t" + str(localtime) + "\n" + str(filedata)

file = open("F:/School/Semester3/GIS4309/my_id_tags.txt", "w")

file.write(newLine)
file.close()


If anyone has found a solution to this problem I would appreciate your help.

Thanks,

Nick

Outcomes