Link to home
Create AccountLog in
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Avatar of Andy Brown
Andy Brown🇬🇧

Pasting files from the clipboard (via Microsoft Access / VBA)
I have an Access application that needs to take files from a users clipboard and paste them to a pre-designated folder.  For example, the user has two Excel files that he has copied from his Desktop, and through vba, I need to offer a function that will paste those two files into D:\PastedFiles (or something like that).

I know there are security implications, which I will address later. But for now, I just need a way to paste the files.

Any suggestions would be greatly appreciated.

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of crystal (strive4peace)crystal (strive4peace)

Since you want to use Access to paste, Access should also identify the files.  You can use the File Dialog, browse to the Desktop (or wherever files are), and allow multi-select.  Then Access can get the path\filename(s) and copy them to where they need to go.

Problem with using what is on the clipboard is that objects, not the path\filenames, are there

Avatar of Andy BrownAndy Brown🇬🇧

ASKER

Hi Crystal - hope all is well.

The problem with the File Dialog is that it allows users to move around the folders (I have just posted a question about that as it will cause me a security issue).

Objects - I see what you mean - I'd also have to check to make sure the objects were indeed files etc.

thanks, Andy

in that case, what you could do is load the filenames to pick from into a multi-select listbox and process the selected files

I'll post some code in a few minutes

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Andy BrownAndy Brown🇬🇧

ASKER

I'm not sure how that will work.

My application will be on a hosted server, which complicates the issue as they won't be able to open their local filesystem (through the server).  If the items were in the clipboard (and assuming they are files), pasting would work....but this is where I have having trouble.

Hi Andy,

if they cannot access their local file system (why is that?), then where are the files going to get copied to? Could you please explain a bit more? And what is the purpose? thank you.

Avatar of Rey Obrero (Capricorn1)Rey Obrero (Capricorn1)🇺🇸

one way to do this is to create a table with the particular Folder Path.
this way you can always direct via code to go to that folder.

before pasting the copied files, check for the folder path to be the same as the one in the table.

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of Andy BrownAndy Brown🇬🇧

ASKER

Sorry - they can access it locally (in order to copy the Excel files for example), but when they switch back to the Access database (running on the remote server), they won't have permissions to open up Explorer.

Avatar of Andy BrownAndy Brown🇬🇧

ASKER

Ultimately, I just want them to be able to copy a couple of files from their local PC, open up the Access Application and through that application, give them the ability to paste those files into a pre-determined folder, which I/the software controls.

I am making an example for you using a multi-select listbox

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of Andy BrownAndy Brown🇬🇧

ASKER

Wow - thank you.

ASKER CERTIFIED SOLUTION
Avatar of crystal (strive4peace)crystal (strive4peace)

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

hi Andy,

if the local file system is not accessible (before you make that determination, however, test it (if I understood correctly, it works with the file dialog -- it may work in the server application, or work with modification since Desktop is a special folder, or perhaps there is a folder that both environments can see and share*), rather than incorporating the above code into the server application, code could run from a stand-alone desktop database on each local drive.  To transfer files, FTP is an alternative to FileCopy*.

*or FileCopy could be to a folder that is synchronized. GetDesktopPath (late-binding to be more transportable) is isolated and easy to swap for another function that gets this folder.  The server application could use this synchronized folder  ... or poll it and move the files it finds -- and/or there could be a command button to get them.

This process could also be modified, if it needs to run stand-alone, to run in Excel -- if that is the comfort zone ... and especially since that is where the files in your example are coming from.

As for tracking files, if you need to do that, file information can be obtained by the server application and written to wherever it needs to go.

Avatar of Andy BrownAndy Brown🇬🇧

ASKER

Thanks Crystal - that works fine and is very helpful (for something I'm about to do) - brilliant.  However, I wasn't clear enough on my original question, so will post that now.

Thank you so much for this answer though.

Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


thanks and you're welcome, Andy ~ happy to help
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.