LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Trefor
 
Posts: n/a
Default Problems copying XLA file

In MAIN.XLS I check to see if the MACRO.XLA file on a network drive is more
up to date than the file in Application.UserLibraryPath. If it is more up to
date, I want to update / copy over the old file in user lib.

If I attempt to copy the XLA and it is currently open, I get an Error = 70
(Permission denied) on the source of the copy. So I added a macro to the XLA
(Force_Close_XLA) which simply closes the XLA. BUT when I do this the sub
routine in MAIN.XLS ends following the execution of Force_Close_XLA.

Is it possible to copy an open file or retain contol in MAIN.XLS?

MACRO.XLA:

Sub Force_Close_XLA()
ThisWorkbook.Close SaveChanges:=False
End Sub


MAIN.XLS:

Sub Update()
If (SourceDate < TargetDate) Or (SourceSize < TargetSize) Then
' MsgBox "" & SourceDate & "<" & TargetDate & "<" & Chr(10) _
' & "" & SourceSize & "<" & TargetSize & "<"
' On Error Resume Next
' Run "MACRO.XLA!Force_Close_XLA"
' On Error GoTo 0
FileCopy MainPath & "\MACRO.XLA", Application.UserLibraryPath &
"MACRO.XLA" ' Copy source to target.
LastError = Err
On Error GoTo 0
If LastError = 70 Then
MsgBox "Permission denied Error " & LastError & " updating file:
" & Application.UserLibraryPath & "MACRO.XLA"
ElseIf LastError < 0 Then
MsgBox "Error " & LastError & " updating file: " &
Application.UserLibraryPath & "MACRO.XLA"
End If
End If

--
Trefor
 
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
copy excell file to a CSV file and than to Notepad need to know bob Excel Discussion (Misc queries) 0 August 23rd 05 07:27 PM
Problems with read only and copying canieleader Excel Discussion (Misc queries) 1 July 26th 05 11:33 PM
MS Office 2003 file opening problems noblep Excel Discussion (Misc queries) 1 March 19th 05 06:21 PM
Locating a file in excel with a partial file name. Audra Excel Discussion (Misc queries) 2 February 19th 05 08:52 PM
Problems copying street addresses and dates C. Dales Excel Discussion (Misc queries) 4 February 11th 05 01:43 PM


All times are GMT +1. The time now is 02:25 AM.

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"