Solved VBA Export to Excel Permissions (1 Viewer)

LiziM

New member
Local time
Today, 09:39
Joined
Feb 3, 2021
Messages
21
Hi all :) I am trying to create a button that, when clicked, opens a file dialog so the user can choose where to have "tbl_Transaction_Master" exported from Access as an Excel spreadsheet.

I am getting the following error when I try and export the Excel doc to my desktop (my desktop folder is not open and I have tested it with other folders too):
"
Run-time error '3051':
The Microsoft Access database enginer cannot open or writ to the file 'C:\Users\Lizi\Desktop'. It is alread opened exclusively by another user,or you need permission to view and write its data.
"
The error occurs at the following line of code:
Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, dbTable, xlWorksheetPath, True

However, when I check my permissions properties for my Desktop folder, as the pic below shows, I do have read and write permissions. Hope someone can help :)
1612699453892.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:39
Joined
Sep 21, 2011
Messages
14,050
That is NOT a file though?, just a folder path?
You need to append "\" and the actual filename with ".xlsx" or similar to create the file.

Showing the actual code would help?
 

LiziM

New member
Local time
Today, 09:39
Joined
Feb 3, 2021
Messages
21
Thank you for your help. That worked. Also noticed I was passing an invalid document name before (it contained "/" and ":"), which I have fixed now, thanks again!
 

Users who are viewing this thread

Top Bottom