Rename closed workbook

W

wally

I AM USING

sub file_in_network_folder()
application.screenupdating = false
on error resume next

'call the macro getrange
getrange \"c:\data\\"test.xls\", \"test\", \"a1:h180\", _
sheets(\"sheet1\").range(\"bb2\")

on error goto 0
application.screenupdating = true
end sub

sub getrange(filepath as string, filename as string, sheetname as
string, _
sourcerange as string, destrange as range)

dim start

'go to the destination range
application.goto destrange

'resize the destrange to the same size as the sourcerange
set destrange = destrange.resize(range(sourcerange).rows.count, _
range(sourcerange).columns.count)

'add formula links to the closed file
with destrange
..formulaarray = \"='\" & filepath & \"/[\" & filename & \"]\" &
sheetname _
& \"'!\" & sourcerange

'wait
start = timer
do while timer < start + 2
doevents
loop

'make values from the formulas
..copy
..pastespecial xlpastevalues
..cells(1).select
application.cutcopymode = false
end with



TO GET DATA I NEED FROM A CLOSED WORKBOOK.
BUT I NEED TO RENAME THE CLOSED WORKBOOK TO THE CURRENT NAME WITH A
DATE STAMP ON THE END.





I ALSO AM USING

private sub workbook_beforeclose(cancel as boolean)
with activeworkbook
..saveas filename:=.path & \"\\" &
..worksheets(\"sheet1\").range(\"p1\").value, _
fileformat:=xlworkbooknormal
end with
end sub


TO CLOSE A WORKBOOK, BUT I NEED TO CLOSE IT AS READ ONLY.



thank for any info.
 
L

Leith Ross

Hello Wally,

To rename any file, in this case a workbook, use NAME <old path & file
name> AS <new path & file name>.

Sincerely,
Leith Ross
 
W

wally

Thanks Leith,
I am able to get that working, but i am unable to get the code righ
for the date or time stamp. any ideas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top