Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

saving open workbook to text string in cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andyjim - 25 Jan 2008 12:18 GMT
I am trying to saving a file based on the text name in a designated cell in
the workbook.  In other words, I am trying to save the open file as the name
that is in a cell in that open file's worksheet.  Evidently, the code below
is not the way to approach it.  I get an out of subscript error.  Can anyone
point me in the right direction?  It seems like this shouldn't be such a hard
thing, but I am baffled.

However, with this code, I get an “subscript out of range”
error. I am running out of ideas. There must be a way to do this! Seems
to be problem with variable.

Thanks for your help.

Windows("fxRM_Update.xls").Activate

Dim bk As Workbook, bk1 As Workbook
Dim sstr As String
Dim path2 As String
path2 = ActiveWorkbook.Path

Set bk = Workbooks("fxRM_update.xls")
sstr = bk.Worksheets("lookup").Range("d39").Value
Set bk1 = Workbooks(sstr) THIS IS WHERE SUBSCRIPT ERROR OCCURS

ActiveWorkbook.SaveCopyAs filename:= bk1
'bk1.saveas
'ActiveWorkbook.SaveCopyAs filename:= p & bk1
' ActiveWorkbook.SaveCopyAs filename:=path2 & "\" & bk1
Per Jessen - 25 Jan 2008 12:45 GMT
Hi

This should do it.

Windows("fxRM_Update.xls").Activate
Dim SaveString As String
Dim sstr As String
Dim Path2 As String

Path2 = ActiveWorkbook.Path
sstr = Worksheets("lookup").Range("d39").Value
SaveString = Path2 & "\" & sstr & ".xls"
ActiveWorkbook.SaveCopyAs Filename:=SaveString

Regards,

Per

>  I am trying to saving a file based on the text name in a designated cell
> in
[quoted text clipped - 29 lines]
> 'ActiveWorkbook.SaveCopyAs filename:= p & bk1
> ' ActiveWorkbook.SaveCopyAs filename:=path2 & "\" & bk1
FSt1 - 25 Jan 2008 12:59 GMT
hi,
you're missing someting.
sstr is not a workbook yet. so i would dump this line....
Set bk1 = Workbooks(sstr)
and replace it with....
ActiveWorkbook.SaveCopyAs Filename:=sstr & ".xls"

regards
FSt1

>   I am trying to saving a file based on the text name in a designated cell in
> the workbook.  In other words, I am trying to save the open file as the name
[quoted text clipped - 24 lines]
> 'ActiveWorkbook.SaveCopyAs filename:= p & bk1
> ' ActiveWorkbook.SaveCopyAs filename:=path2 & "\" & bk1
DomThePom - 25 Jan 2008 13:11 GMT
Name the cell where you have the full path and fielname as say rngFilename

then the only line of code you need is:

ActiveWorkbook.SaveAs Filename range("rngFileName").value

>   I am trying to saving a file based on the text name in a designated cell in
> the workbook.  In other words, I am trying to save the open file as the name
[quoted text clipped - 24 lines]
> 'ActiveWorkbook.SaveCopyAs filename:= p & bk1
> ' ActiveWorkbook.SaveCopyAs filename:=path2 & "\" & bk1
Andyjim - 25 Jan 2008 13:15 GMT
Thanks to both of you for such a speedy response!  I will try this at the
first opportunity!

> Name the cell where you have the full path and fielname as say rngFilename
>
[quoted text clipped - 30 lines]
> > 'ActiveWorkbook.SaveCopyAs filename:= p & bk1
> > ' ActiveWorkbook.SaveCopyAs filename:=path2 & "\" & bk1
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.