Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need urgent help with VB Code

Status
Not open for further replies.

fabiousa

MIS
Aug 13, 2001
45
BR
Hey Guys,

I bet there are lots of experts here.
I am about to ask a question that I am not eve sure if it's related to VB. I hope so.

We have a macro that reads, from a Excel spreadsheet, some data and write them in another application.
I have never changed the code and it used to work fine.
Since a time ago, when I try to run it, I get an error message saying: "Execution Time Error 5" and then one line of the code gets yellow.
The yellow line is: AppActivate ReturnValue

And the code from top until the error is found follows below.
Can you by the code below help me out and tell me what's wrong and WHY it's not working now since I haven't made any amendments to it...
I am a complete DUMB regarding VB (hope the code is in VB).
Thanks a lot in avance!

Fabio



Option Compare Database
Option Explicit

Sub CreateDiccionario()

Dim ReturnValue, I
Dim wrk As Workspace
Dim db As Database
Dim TDict As Recordset
Dim PrimeraVar As Boolean

'Open the workspace, the database and the table with the information about the
'characteristics
Set wrk = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wrk.OpenDatabase("C:\WINNT\Profiles\Administrator\Desktop\macro.mdb")
Set TDict = db.OpenRecordset("SPC", dbOpenSnapshot) 'HERE

'Run Dictionary
ReturnValue = Shell("c:\ccnprod\system\global\dict32.exe", vbNormalFocus)
'Activate Dictionary
AppActivate ReturnValue

'file open; lost time while wait the dictionary is active
SendKeys "superuser{TAB}mega{TAB 2}{ENTER}", True
For I = 1 To 250
SendKeys "%(f)o"
Next I


....code continues
 
AppActivate ReturnValue
wants a string or the return value from the "Shell". I imagine the the Shell is failing and AppActivat does not like a 0.
Shell
"Runs an executable program and returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero."

Perhaps
ReturnValue = Shell("c:\ccnprod\system\global\dict32.exe", vbNormalFocus)
fails because file
c:\ccnprod\system\global\dict32.exe
does not exist anymore.


Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top