ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Rename closed workbook (https://www.excelbanter.com/excel-programming/366375-rename-closed-workbook.html)

wally[_3_]

Rename closed workbook
 

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.


--
wally
------------------------------------------------------------------------
wally's Profile: http://www.excelforum.com/member.php...o&userid=36088
View this thread: http://www.excelforum.com/showthread...hreadid=558702


Leith Ross[_636_]

Rename closed workbook
 

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


--
Leith Ross


------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=558702


wally[_4_]

Rename closed workbook
 

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

--
wall
-----------------------------------------------------------------------
wally's Profile: http://www.excelforum.com/member.php...fo&userid=3608
View this thread: http://www.excelforum.com/showthread.php?threadid=55870



All times are GMT +1. The time now is 11:32 PM.

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