Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to copy a file already open with VBA ?

Hi,

I'm looking for a solution to make a copy of a file already open.
Function FILECOPY doesn't work because this file is already open...
The file I want to copy is a SYS file so it's impossible to open it in Excel
and save it as...

Would anyone have an idea about it ? If yes, could you please write me a
line of code as example.

Thanks,

Franck V.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to copy a file already open with VBA ?

Dim FSO as FileSystemObject
set FSO = new FileSystemObject

FSO.CopyFile "C:\test.sys", "D:\My Folder"

--
Regards,
Tom Ogilvy



"Franck V." wrote in message
...
Hi,

I'm looking for a solution to make a copy of a file already open.
Function FILECOPY doesn't work because this file is already open...
The file I want to copy is a SYS file so it's impossible to open it in

Excel
and save it as...

Would anyone have an idea about it ? If yes, could you please write me a
line of code as example.

Thanks,

Franck V.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to copy a file already open with VBA ?

"Franck V." wrote in message ...
Hi,

I'm looking for a solution to make a copy of a file already open.
Function FILECOPY doesn't work because this file is already open...
The file I want to copy is a SYS file so it's impossible to open it in Excel
and save it as...

Would anyone have an idea about it ? If yes, could you please write me a
line of code as example.

Thanks,

Franck V.


Would something like this do it?

Private Declare Function CopyFile _
Lib "kernel32" _
Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long

Sub test()
CopyFile "C:\Temp\test.txt", "C:\Temp\test2.txt", 0&
End Sub
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
Open HTML file, but doesn't copy correctly Kmason5727 Excel Worksheet Functions 0 October 24th 08 04:47 AM
Save copy of file to open as read only Ray Clark[_2_] Excel Discussion (Misc queries) 2 June 20th 08 12:19 AM
Open and copy all workbook sheets in a folder to a master file [email protected] Excel Discussion (Misc queries) 0 November 2nd 06 04:29 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
File does not open/copy Ken Goodwin Excel Programming 1 August 6th 03 02:41 AM


All times are GMT +1. The time now is 12:21 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"