Guest User

Untitled

a guest
Aug 20th, 2019
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub CreateDatabase()
  2. ThisWorkbook.Activate
  3. Sheets("SalaryTab").Select
  4. Sheets("SalaryTab").Range("A1:CU1499").Select
  5.  
  6. Dim strPath As String
  7. Dim databaseAccess As Object
  8. Const acImport = 0
  9.  
  10. strPath = "C:SecretFolderSecretDB"
  11. Set databaseAccess = CreateObject("Access.Application")
  12. Call databaseAccess.NewCurrentDatabase(strPath)
  13.  
  14. databaseAccess.CurrentProject.Connection.Execute ("Create Table AccessSecretTable")
  15.  
  16. '<<<<The below line gives an error "Variable not defined."
  17. DoCmd.TransferSpreadsheet acImport, 10, "AccessSecretTable", "C:SecretFolderPayroll.xlsb", True, "SalaryTab!A1:CU1499"
  18.  
  19. databaseAccess.Quit
  20. End Sub
RAW Paste Data