Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Moving a disk file with VBA

Hi

Can someone point me in the right direction please.
I want to copy an access database from one disk location to another using
VBA.

The reason for this is that I have an odbc link to a database and I want to
use it to read a different database without having to rebuild the query. I
have found that for me the easiest way to do this is to copy the live
database into a temporary location which msquery can read, then to change
the database just copy the new database over the top. But I want to do this
all from within excel.

So any pointerswould be appreciated.

Many Thanks

Chris


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Moving a disk file with VBA

Chris, you can call the following function or just insert the "FileCopy" line
where you want it and replace the arguments with the full paths (i.e. drive,
path, file name, file extension):

Public Function FileCopy(argFullSourceName As String, argFullDestinationName
As String)
'COPY A CLOSED FILE FROM ONE FOLDER TO ANOTHER;
FileCopy argFullSourceName, argFullDestinationName
End Function

HTH

"Chris Ferguson" wrote:

Hi

Can someone point me in the right direction please.
I want to copy an access database from one disk location to another using
VBA.

The reason for this is that I have an odbc link to a database and I want to
use it to read a different database without having to rebuild the query. I
have found that for me the easiest way to do this is to copy the live
database into a temporary location which msquery can read, then to change
the database just copy the new database over the top. But I want to do this
all from within excel.

So any pointerswould be appreciated.

Many Thanks

Chris



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving a disk file with VBA

Just some added info:
Even though the OP said move in his subject, he said copy in the body. the
Name command will move the file. The Filecopy command will copy it.

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
this should do it
Sub movefile()
OldName = "C:\oldfolder\1065.xls"
NewName = "C:\newfolder\1065.xls"
Name OldName As NewName
End Sub

--
Don Guillett
SalesAid Software

"Chris Ferguson" wrote in message
...
Hi

Can someone point me in the right direction please.
I want to copy an access database from one disk location to another

using
VBA.

The reason for this is that I have an odbc link to a database and I want

to
use it to read a different database without having to rebuild the query.

I
have found that for me the easiest way to do this is to copy the live
database into a temporary location which msquery can read, then to

change
the database just copy the new database over the top. But I want to do

this
all from within excel.

So any pointerswould be appreciated.

Many Thanks

Chris






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Moving a disk file with VBA

Brilliant, thanks guys, the copyfile was exactly what I wanted.

Why is it so obvious, just after it has been pointed out?

Chris
"Tom Ogilvy" wrote in message
...
Just some added info:
Even though the OP said move in his subject, he said copy in the body. the
Name command will move the file. The Filecopy command will copy it.

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
this should do it
Sub movefile()
OldName = "C:\oldfolder\1065.xls"
NewName = "C:\newfolder\1065.xls"
Name OldName As NewName
End Sub

--
Don Guillett
SalesAid Software

"Chris Ferguson" wrote in message
...
Hi

Can someone point me in the right direction please.
I want to copy an access database from one disk location to another

using
VBA.

The reason for this is that I have an odbc link to a database and I
want

to
use it to read a different database without having to rebuild the
query.

I
have found that for me the easiest way to do this is to copy the live
database into a temporary location which msquery can read, then to

change
the database just copy the new database over the top. But I want to do

this
all from within excel.

So any pointerswould be appreciated.

Many Thanks

Chris










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Moving a disk file with VBA

Brilliant.

Thats just what I wanted.

Thanks very much.
"Tom Ogilvy" wrote in message
...
Just some added info:
Even though the OP said move in his subject, he said copy in the body. the
Name command will move the file. The Filecopy command will copy it.

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
this should do it
Sub movefile()
OldName = "C:\oldfolder\1065.xls"
NewName = "C:\newfolder\1065.xls"
Name OldName As NewName
End Sub

--
Don Guillett
SalesAid Software

"Chris Ferguson" wrote in message
...
Hi

Can someone point me in the right direction please.
I want to copy an access database from one disk location to another

using
VBA.

The reason for this is that I have an odbc link to a database and I
want

to
use it to read a different database without having to rebuild the
query.

I
have found that for me the easiest way to do this is to copy the live
database into a temporary location which msquery can read, then to

change
the database just copy the new database over the top. But I want to do

this
all from within excel.

So any pointerswould be appreciated.

Many Thanks

Chris








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I still recover a file I saved in USB Flash disk from my HDD? arunas Excel Discussion (Misc queries) 2 February 7th 10 07:41 PM
Save a file to disk without re-formating the disk Frustrated Mike Excel Discussion (Misc queries) 2 February 19th 09 07:33 PM
File has grown to 300,000 KB on Disk Jim May Excel Discussion (Misc queries) 12 December 7th 07 09:18 PM
missing MSOCache file not on program disk fdjmn Setting up and Configuration of Excel 0 May 25th 06 08:54 AM
Download files from 3.5 disk in excel but system said disk need fo DG Excel Discussion (Misc queries) 0 August 13th 05 04:16 PM


All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"