need help.. VBA in access and excel..

Closed Thread

Join Date: Jun 2006
Posts: 29
Reputation: BombAppetit is an unknown quantity at this point 
Solved Threads: 0
BombAppetit BombAppetit is offline Offline
Light Poster

need help.. VBA in access and excel..

 
0
  #1
Jul 4th, 2006
greetings

i am doing a database system in access and has certain function of creating and modifying an excel worksheet. i keep getting this "Run-time error '462' : Remote server machine doesn't exist or is unavailable" or sometimes "Run-time error '1004' : Method 'Range' of object '_Global' failed"..
it points to this line
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Range(checker1).Select
when i click on one of my command button
as well as
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ActiveWorkbook.Close True
in a different command button.

here's the code for the function that is called when some1 clicks the command button

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim checker(5) As String
  2. Dim insertion As Integer
  3. OpenExcel
  4. Set xlApp = CreateObject("Excel.Application")
  5. Set xlBook = xlApp.Workbooks.Open("C:\Osman\ABP-FET Reference.xls")
  6. insertion = 0
  7. Do
  8. MsgBox (insertion) 'i added this for trial runs only, to check if it
  9. ' follows the correct sequence
  10.  
  11. Set xlSht = xlBook.Worksheets("Wafer Sort")
  12. Set xlRng = xlSht.Cells((insertion * 4) + 7, 3)
  13. checker(1) = xlRng.Value
  14. Set xlRng = xlSht.Cells((insertion * 4) + 7, 4)
  15. checker(2) = xlRng.Value
  16.  
  17. Set xlSht = xlBook.Worksheets("Assembly")
  18. Set xlRng = xlSht.Cells((insertion * 4) + 7, 3)
  19. checker(3) = xlRng.Value
  20. Set xlRng = xlSht.Cells((insertion * 4) + 7, 4)
  21. checker(4) = xlRng.Value
  22. insertion = insertion + 1
  23.  
  24. Loop Until checker(1) = "" And checker(2) = "" And checker(3) = "" And checker(4) = "" ' checking for empty cells
  25.  
  26. insertion = ((insertion - 1) * 4) + 7
  27. MsgBox (insertion) 'trial run purposes, to check on which row product
  28. 'will be added
  29. DC = InputBox("Please insert D/C", "Add")
  30. PN = InputBox("Please insert P/N", "Add")
  31. Set xlSht = xlBook.Worksheets("Wafer Sort")
  32. xlSht.Activate
  33. dummy = WaferSortAddProduct(insertion, DC, PN)
  34. Set xlSht = xlBook.Worksheets("Assembly")
  35. xlSht.Activate
  36. dummy = AssemblyAddProduct(insertion, DC, PN)
  37.  
  38. xlApp.Application.UserControl = True
  39. xlApp.Application.Visible = True
  40. ActiveWorkbook.Close True
  41. xlApp.Application.Visible = False
  42. xlApp.Quit
  43.  
  44. Set xlRng = Nothing
  45. Set xlSht = Nothing
  46. Set xlBook = Nothing
  47. Set xlApp = Nothing

OpenExcel function has the declarations for xlApp etc2..
the pointed error "Range(checker1).Select" exists in the functions "WaferSortAddProduct" and "AssemblyAddProduct", which i stored in a module, which btw, this function also exists in the same module... i use the range and select thing to modify the property of the cells, some merging, fonts, formula, borders and default values. i copy and modify it from excel recorded macros.

weird thing is, it works on the first run, then on the second run it gives the run time error, which then it works again on the third run and fails on the fourth run.. it goes on and on in that sequence..

also i can't seem to end the excel process.. i tried using all the codes that i could get my hands on but none of them actually ends the process.. after each try i have to manually end the process in task manager..

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. xlApp.Quit
  2. Set xlRng = Nothing
  3. Set xlSht = Nothing
  4. Set xlBook = Nothing
  5. Set xlApp = Nothing

i'm getting really frustrated over this part.. i'd really appreciate any form of help/feedback.. thanks in advance

-osman-
Last edited by BombAppetit; Jul 4th, 2006 at 11:45 pm.
Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: need help.. VBA in access and excel..

 
0
  #2
Jul 6th, 2006
Hmn, I don't seem to get that error when I run your code on my box... I wasn't sure how your ABP-FET Reference.xls file looks, so I kind of guessed, and maybe that's the issue (probably, if it's a problem with a text range), but umn..... it seems to work for me....maybe you could attach both the .xls file and the .vbs file in a .zip file.
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC