Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-18-2019, 07:08 AM   #1
Alhakeem1977
Newly Registered User
 
Join Date: Jun 2017
Posts: 155
Thanks: 72
Thanked 0 Times in 0 Posts
Alhakeem1977 is on a distinguished road
Cut & Past .pdf file from a folder to one another in Microsoft Access

Hi,

How can I achive a Microsoft Access db that can cut a .pdf file from one folder to one another and rename it by selecting the file from a listbox to another listbox within a form called frmFileManager ?

CUT From folder path B:\FOR REVIEW
File name is variable as:
16JUN19-DDB-001.pdf


PAST TO folder path B:\COMPLETED
File name will be renamed as:
16JUN19-DDB-001DONE.pdf

Any suggestions how to build a VBA to achieve this action?

Thanks in advance!


Sent from my HUAWEI NXT-L29 using Tapatalk

Alhakeem1977 is offline   Reply With Quote
Old 06-18-2019, 07:21 AM   #2
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,893
Thanks: 40
Thanked 3,532 Times in 3,415 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: Cut & Past .pdf file from a folder to one another in Microsoft Access

use the filecopy and kill functions

Code:
filecopy B:\FOR REVIEW\16JUN19-DDB-001.pdf, B:\COMPLETED\16JUN19-DDB-001DONE.pdf
kill  B:\FOR REVIEW\16JUN19-DDB-001.pdf
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
The Following User Says Thank You to CJ_London For This Useful Post:
Alhakeem1977 (06-18-2019)
Old 06-18-2019, 07:23 AM   #3
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,960
Thanks: 34
Thanked 711 Times in 694 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Cut & Past .pdf file from a folder to one another in Microsoft Access

Hi. I think you can also use the NAME AS statement to "move" a file and rename it at the same time. Cheers!

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Alhakeem1977 (06-18-2019)
Old 06-18-2019, 07:30 AM   #4
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 13,929
Thanks: 79
Thanked 1,563 Times in 1,451 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Cut & Past .pdf file from a folder to one another in Microsoft Access

First, it is possible for you to rename a file from one path to another path on the same drive (which appears to apply to the case you posted).

The following is AIR CODE in that it only is meant to demonstrate a principle. This means I am not even going to bother to DIM anything.

Code:
SrcFldr = "B:\FOR REVIEW\"
SrcFile = "16JUN19-DDB-001.PDF"
DstFldr = "B:\COMPLETED\"
DstFile = "16JUN19-DDB-001DONE.PDF"
SrcSpec = SrcFldr & SrcFile
DstSpec = DstFldr & DstFile
Name SrcSpec As DstSpec
How you go about filling in the file name and folder for each of the components is up to you, but I broke it down into parts just so you could see how to combine the parts once you have them all.

Note also that this only works as you requested if the source and destination are on the same drive. If this crosses physical drives, you need other syntax.

There is also the idea that you could use a File System Object, which would give you access to a whole range of file operations.

https://docs.microsoft.com/en-us/off...mobject-object

The available methods are listed in the linked article. These methods include file copy, file delete, file rename, and a few other useful abilities.

For simplicity, the original "Name As" will work but is limited. For generality, use the File System Object to do full file manipulation.
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
The Following User Says Thank You to The_Doc_Man For This Useful Post:
Alhakeem1977 (06-18-2019)
Old 06-18-2019, 10:24 AM   #5
Alhakeem1977
Newly Registered User
 
Join Date: Jun 2017
Posts: 155
Thanks: 72
Thanked 0 Times in 0 Posts
Alhakeem1977 is on a distinguished road
Re: Cut & Past .pdf file from a folder to one another in Microsoft Access

Quote:
Originally Posted by CJ_London View Post
use the filecopy and kill functions



Code:
filecopy B:\FOR REVIEW\16JUN19-DDB-001.pdf, B:\COMPLETED\16JUN19-DDB-001DONE.pdf

kill  B:\FOR REVIEW\16JUN19-DDB-001.pdf
I would like to select the file from a list box (ListSource) within the form, the file could be with a variable date then move it to another list box (ListTarget) and rename the file let say to add Done to it in the same form but the action will take place in the folder as I stated earlier in my post.

I don't know if it's clear to all of you experts, it's very simple I guess for all of you but it's a bit hard for me to build the code.

Thanks all for your responses.

Sent from my HUAWEI NXT-L29 using Tapatalk
Alhakeem1977 is offline   Reply With Quote
Old 06-18-2019, 11:04 AM   #6
CJ_London
Super Moderator
 
Join Date: Feb 2013
Location: UK
Posts: 10,893
Thanks: 40
Thanked 3,532 Times in 3,415 Posts
CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice CJ_London is just really nice
Re: Cut & Past .pdf file from a folder to one another in Microsoft Access

not clear to me what you are trying to do. listboxes have nothing to do with files. How are you populating the listboxes?
__________________
CJ_London
_______________________
A little thanks goes a long way. If you have found this post useful, please tick the thanks button
CJ_London is offline   Reply With Quote
Old 06-18-2019, 12:22 PM   #7
Alhakeem1977
Newly Registered User
 
Join Date: Jun 2017
Posts: 155
Thanks: 72
Thanked 0 Times in 0 Posts
Alhakeem1977 is on a distinguished road
Re: Cut & Past .pdf file from a folder to one another in Microsoft Access

Quote:
Originally Posted by CJ_London View Post
not clear to me what you are trying to do. listboxes have nothing to do with files. How are you populating the listboxes?
I mean listbox will show me exactly the contents of the source folder and in the other listbox will show me the contents of the Target folder when select one file or more from Source then press a button between them will move the file to the Target listbox (Target folder).

Sent from my HUAWEI NXT-L29 using Tapatalk

Alhakeem1977 is offline   Reply With Quote
Old 06-18-2019, 12:32 PM   #8
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 13,929
Thanks: 79
Thanked 1,563 Times in 1,451 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Cut & Past .pdf file from a folder to one another in Microsoft Access

Your best bet to populate the listbox is to use a FileSystemObject to find all of the eligible files, drop the file spec into a table, and then open up the list box from that table. Since you would have had to use a FileSystemObject to grab this list, you might as well use the other features of the same object to perform file control, copy, rename, and delete operations.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Access Cannot Open This File angelgirl General 10 09-08-2011 01:51 AM
Microsoft Access cannot open this file Qrackerman General 10 10-21-2009 07:22 AM
Editing Microsoft Access file zyzor General 1 08-05-2009 01:58 PM
How to delete a file from folder from Access? Niroth Visual Basic 2 06-20-2009 01:26 AM
Microsoft Access cannot open this file jammyp General 3 11-15-2006 10:10 AM




All times are GMT -8. The time now is 08:16 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World