Computing.Net > Forums > Programming > file name referenced from a cell

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

file name referenced from a cell

Reply to Message Icon

Name: Adrian
Date: January 29, 2003 at 08:23:49 Pacific
OS: xp
CPU/Ram: celeron2 256mb
Comment:

I need some help with a macro,

I need it to saveas a file with the exact name as the contents of a specific cell,

eg cell a1 = 02.02.03.sun.xls
i need the macro to saveas the file as 02.02.03.sun.xls

any ideas,

i saw a post here a while ago similar but cant find it and really need to get this to work.

thanks
Adrian



Sponsored Link
Ads by Google

Response Number 1
Name: jdneal
Date: January 29, 2003 at 14:25:37 Pacific
Reply:

When I need macros like that, I fire up the macro recorder, perform the action, then edit the result.

For example, in my typical export sub-routine, I have something like:

*************************************

sheets(sheet_to_export).copy

outfilename = worksheets(sheetname).rows(cellrow).columns(cellcolumn)

ActiveWorkbook.SaveAs FileName:= filename, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

ActiveWindow.Close

************************************

I didn't read-to-find-out any of that: I recorded a macro that did it, then edited it.

Don't expect to copy and paste that as a whole working piece of code: that is the concept and just one way of doing it.

I use Excel 97 and VBA.

How do you export multiple sheets at once? Start the macro recorder, select several sheets, move them, save them, close the result, stop macro recording, and hunt down the macro you created - it'll show you how.


0

Response Number 2
Name: Shodan
Date: January 30, 2003 at 13:28:51 Pacific
Reply:

Hey, try using this code:

ActiveWorkbook.SaveAs _
(ActiveSheet.Cells(1, 1).Text)

This saves the current workbook named as the contents of cell A1. Note, though, that this saves the file to the current path. You can display the path by using

MsgBox ActiveWorkbook.Path

Post back or e-mail directly if this does/does not help or if you need further assistance.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: file name referenced from a cell

Coping files from a removable drive www.computing.net/answers/programming/coping-files-from-a-removable-drive/15468.html

Search a file name, Batch www.computing.net/answers/programming/search-a-file-name-batch/17080.html

prgrmatically scrambling file names www.computing.net/answers/programming/prgrmatically-scrambling-file-names/8042.html