Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel CurrentProject.Path, runime error 424

Tags:

excel

vba

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

like image 333
Zac Avatar asked Feb 24 '26 02:02

Zac


1 Answers

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

like image 134
GSerg Avatar answered Feb 27 '26 01:02

GSerg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!