ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Release files from memory?? (https://www.excelbanter.com/excel-programming/293483-release-files-memory.html)

Ron[_21_]

Release files from memory??
 
Hello,
Upon closing two files after running a macro that is copying value
from one file to the other I can only reopen them in read only, unles
I reboot. Apparently the files are still in memory. How do I correc
this problem?

Thanks.
Ro

--
Message posted from http://www.ExcelForum.com


Vasant Nanavati

Release files from memory??
 
Your explanation doesn't seem right. How does the macro close the files? Is
it possible that it is just hiding them? Relevant code excerpts would be
helpful.

--

Vasant


"Ron " wrote in message
...
Hello,
Upon closing two files after running a macro that is copying values
from one file to the other I can only reopen them in read only, unless
I reboot. Apparently the files are still in memory. How do I correct
this problem?

Thanks.
Ron


---
Message posted from http://www.ExcelForum.com/




Ivan F Moala[_3_]

Release files from memory??
 
Ron wrote in message ...
Hello,
Upon closing two files after running a macro that is copying values
from one file to the other I can only reopen them in read only, unless
I reboot. Apparently the files are still in memory. How do I correct
this problem?

Thanks.
Ron


---
Message posted from http://www.ExcelForum.com/


Hi Ron, sounds like you are creating another instance of Excel
via the automation method of creatobject or getobject via the New key word.
Either way you need to follow the basics of any COMS enabled
application ie.

1) Establish interface via calls
... do your code
2) close and/or save file/data
3) quit application
4) destroy instance via setting of your obj var that holds the
reference to it = Nothing.

Appologies if this is not the case :-)

Ron[_22_]

Release files from memory??
 
Hi
Below is the code I am using. I open both files, the one I am copyin
to and the one I am coping from. After I run the macro and close bot
files I can only open either file in read only unless I reboot. I a
sure the code has much room for improvement, for I am new at this. An
help will be greatly appreciated.
Ron

Application.ScreenUpdating = False

Dim rRCount As Integer
Dim cRCount As Integer
Dim rSCount As Integer
Dim cSCount As Integer
Dim LoopNo As Integer

rRCount = 15
cRCount = 5
rSCount = 7
cSCount = 4

pass = False

For x = 1 To 19

If pass = True Then
rRCount = 63
cRCount = 5
rSCount = 11
cSCount = 4
pass = False
End If

If x = 3 Then
cRCount = cRCount - 8
rSCount = rSCount - 4
End If

If x = 17 Then
rRCount = rRCount - 1
End If

If x = 18 Then
rRCount = rRCount - 1
End If

LoopNo = 4

If x = 19 Then
LoopNo = 3
End If

For A = 1 To LoopNo

Windows("Appendix C FFP Off-site Att 3.xls").Activate
Sheets("Base year").Select
Cells(rRCount, cRCount).Select
Selection.Copy
Windows("FFP Rates Off-Site TE B.xls").Activate
Sheets("FFP Base Yr").Select
Cells(rSCount, cSCount).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

rRCount = rRCount + 0
cRCount = cRCount + 2
rSCount = rSCount + 1
cSCount = cSCount + 0
Next A

If x < 2 Then
pass = True
Else
pass = False
End If

rRCount = rRCount + 48
cRCount = cRCount + 0
rSCount = rSCount + 4
cSCount = cSCount + 0

Next x

End Su

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 01:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com