ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Another SaveAs Question (https://www.excelbanter.com/excel-programming/358333-another-saveas-question.html)

chipshot[_2_]

Another SaveAs Question
 

In the code below I cannot get the saveas that uses the variable driven
filename to save. It executes without error and the correct value is
shown in the message box and if I use the debugger the correct value is
in the strFilename variable but nothing is saved. However the hardcoded
filename saves fine. Is there anything I might be overlooking in terms
of application settings or anything I am overlooking? I have two
similar verions. It works in one but not the other.

Dim strFilename as String
strFilename = Range("c4") & ".xls"


With ActiveWorkbook
msgbox strFilename
.SaveAs FileName:="C:\Pricing Model\" & strfilename
.SaveAs FileName:="C:\Pricing Model\test.xls"
.Close False
End With



--
chipshot
------------------------------------------------------------------------
chipshot's Profile: http://www.excelforum.com/member.php...o&userid=27701
View this thread: http://www.excelforum.com/showthread...hreadid=530964


chipshot[_3_]

Another SaveAs Question
 

Bueller?....................


--
chipshot
------------------------------------------------------------------------
chipshot's Profile: http://www.excelforum.com/member.php...o&userid=27701
View this thread: http://www.excelforum.com/showthread...hreadid=530964


Dave Peterson

Another SaveAs Question
 
Did you look in that Pricing Model folder for a file that has a name that
matches strfilename?

Your back-to-back .saveAs would leave test.xls as the activeworkbook.

If that doesn't work, you may want to post your actual code.

chipshot wrote:

In the code below I cannot get the saveas that uses the variable driven
filename to save. It executes without error and the correct value is
shown in the message box and if I use the debugger the correct value is
in the strFilename variable but nothing is saved. However the hardcoded
filename saves fine. Is there anything I might be overlooking in terms
of application settings or anything I am overlooking? I have two
similar verions. It works in one but not the other.

Dim strFilename as String
strFilename = Range("c4") & ".xls"


With ActiveWorkbook
msgbox strFilename
.SaveAs FileName:="C:\Pricing Model\" & strfilename
.SaveAs FileName:="C:\Pricing Model\test.xls"
.Close False
End With


--
chipshot
------------------------------------------------------------------------
chipshot's Profile: http://www.excelforum.com/member.php...o&userid=27701
View this thread: http://www.excelforum.com/showthread...hreadid=530964


--

Dave Peterson

chipshot[_4_]

Another SaveAs Question
 

I just put them back to back to show which one works and which one
doesn't. It does the same thing when the directory is empty. If I take
out the hard coded line it makes no differance.


--
chipshot
------------------------------------------------------------------------
chipshot's Profile: http://www.excelforum.com/member.php...o&userid=27701
View this thread: http://www.excelforum.com/showthread...hreadid=530964


Dave Peterson

Another SaveAs Question
 
You may want to post your actual code.

And what's in that cell.

chipshot wrote:

I just put them back to back to show which one works and which one
doesn't. It does the same thing when the directory is empty. If I take
out the hard coded line it makes no differance.

--
chipshot
------------------------------------------------------------------------
chipshot's Profile: http://www.excelforum.com/member.php...o&userid=27701
View this thread: http://www.excelforum.com/showthread...hreadid=530964


--

Dave Peterson

GregR

Another SaveAs Question
 
Chipshot, what is the value of "C4"?

Greg


Tom Ogilvy

Another SaveAs Question
 
from what I can see, if everything is fine, it should work. If it doesn't
work, something must not be fine. does the value of strfilename have the
extension ".xls"?

--
Regards,
Tom Ogilvy


"chipshot" wrote:


In the code below I cannot get the saveas that uses the variable driven
filename to save. It executes without error and the correct value is
shown in the message box and if I use the debugger the correct value is
in the strFilename variable but nothing is saved. However the hardcoded
filename saves fine. Is there anything I might be overlooking in terms
of application settings or anything I am overlooking? I have two
similar verions. It works in one but not the other.

Dim strFilename as String
strFilename = Range("c4") & ".xls"


With ActiveWorkbook
msgbox strFilename
.SaveAs FileName:="C:\Pricing Model\" & strfilename
.SaveAs FileName:="C:\Pricing Model\test.xls"
.Close False
End With



--
chipshot
------------------------------------------------------------------------
chipshot's Profile: http://www.excelforum.com/member.php...o&userid=27701
View this thread: http://www.excelforum.com/showthread...hreadid=530964



chipshot[_5_]

Another SaveAs Question
 

I've done it with it there and without it. Thing is when it's hard coded
it will work with or without the .xls extension as well, it
automatically appends it. I'm thinking it really isn't a coding issue
but some other unknown quirk.


--
chipshot
------------------------------------------------------------------------
chipshot's Profile: http://www.excelforum.com/member.php...o&userid=27701
View this thread: http://www.excelforum.com/showthread...hreadid=530964



All times are GMT +1. The time now is 06:22 PM.

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