3

I have never ever done anything in VBA for excel before. I have my whole dashboard working when the .accdb is in C drive but now i want it in the same folder as excel workbook.

Im getting "Run-time error '424: Object required" for the bottom line below

Dim DatabasePath As String
DatabasePath = CurrentProject.Path & "\SpreadSheetData.accdb"

Why is this? Thanks for your help

Zac
  • 121
  • 2
  • 3
  • 10
  • 3
    Put `Option Explicit` at the top of your modules. This will save you from headaches like this. [see this](http://stackoverflow.com/questions/1139321/how-do-i-force-vba-access-to-require-variables-to-be-defined/1139522#1139522) – Brad Mar 01 '13 at 16:49

1 Answers1

6

There is no CurrentProject in Excel. If you want to refer to the workbook in which the executing code resides, use ThisWorkbook instead.

GSerg
  • 76,472
  • 17
  • 159
  • 346