code_junkie

How to write data from access to excel file

Nov 12th, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. Dim objexcel As Excel.Application
  2. Dim wbexcel As Excel.Workbook
  3. Dim wbExists As Boolean
  4. Set objexcel = CreateObject("excel.Application")
  5. objexcel.Visible = True
  6. On Error GoTo Openwb
  7. wbExists = False
  8. Set wbexcel = objexcel.Documents.Open("C:Documents and SettingsTAYYAPPDesktoptest folderERROR REPORT2.xls")
  9. wbExists = True
  10. Openwb:
  11.  
  12. On Error GoTo 0
  13. If Not wbExists Then
  14. Set wbexcel = objexcel.Workbook.Add
  15. End If
  16.  
  17. Set wbexcel = objexcel.Workbook.Add
  18.  
  19. Set wbexcel = objexcel.WorkBooks.Open( _
  20. "C:Documents and SettingsTAYYAPPDesktoptest folderERROR REPORT2.xls")
  21.  
  22. objexcel.Workbooks.Add
  23. Set wbexcel = objexcel.ActiveWorkbook
  24.  
  25. Dim objexcel As Excel.Application
  26. Dim wbexcel As Excel.Workbook
  27. Dim wbExists As Boolean
  28. Dim objSht As Excel.Worksheet
  29. Dim objRange As Excel.Range
  30.  
  31.  
  32. Set objexcel = CreateObject("excel.Application")
  33. objexcel.Visible = True
  34. On Error GoTo Openwb
  35. wbExists = False
  36. Set wbexcel = objexcel.Workbooks.Open("C:Documents and SettingsTAYYAPPDesktoptest folderreportsERROR REPORT2.xls")
  37. Set objSht = wbexcel.Worksheets("Sheet1")
  38. objSht.Activate
  39. wbExists = True
  40. Openwb:
  41.  
  42. On Error GoTo 0
  43. If Not wbExists Then
  44. objexcel.Workbooks.Add
  45. Set wbexcel = objexcel.ActiveWorkbook
  46. Set objSht = wbexcel.Worksheets("Sheet1")
  47.  
  48. End If
Add Comment
Please, Sign In to add comment