ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excel save AND concatenation problem (https://www.excelbanter.com/excel-programming/291415-excel-save-concatenation-problem.html)

Greg85374

excel save AND concatenation problem
 
can someone help me with this?


Public lpfilename As String

Sub Macro1()

lpfilename = Range("f7")
ActiveWorkbook.SaveAs Filename:="C:\Documents and
Settings\Administrator\My Documents\" & lpfilename,
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False

End Sub


I believe i need to put quotes on each side of lpfilename...I would
like also in general to know how to do somehting similar to """ (quote
inside quotes) for future reference....By the way F7 is a date
stamp..Thanks much again guys youve all been excellent!


---
Message posted from http://www.ExcelForum.com/


Tom Ogilvy

excel save AND concatenation problem
 
No, you don't need to put quotes on each side of lpfilename unless you want
a file literally named

lpfilename.xls

if it is a date stamp then use

Sub Macro1()

lpfilename = Range("f7").Text
ActiveWorkbook.SaveAs Filename:="C:\Documents and
Settings\Administrator\My Documents\" & lpfilename,
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False

End Sub

to get the formatted date. (as displayed). However, you probably don't want
slashes in your filename, so you might use another format


lpfilename = format(Range("f7").Value,"yyyymmdd")


To put a quote in a text string

sStr = "The name of the book, ""The House on the Hill,"" was visible to all"

verifying in the immediate window:
sStr = "The name of the book, ""The House on the Hill,"" was visible to all"
? sStr
The name of the book, "The House on the Hill," was visible to all



--
Regards,
Tom Ogilvy



"Greg85374 " wrote in message
...
can someone help me with this?


Public lpfilename As String

Sub Macro1()

lpfilename = Range("f7")
ActiveWorkbook.SaveAs Filename:="C:\Documents and
Settings\Administrator\My Documents\" & lpfilename,
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False

End Sub


I believe i need to put quotes on each side of lpfilename...I would
like also in general to know how to do somehting similar to """ (quote
inside quotes) for future reference....By the way F7 is a date
stamp..Thanks much again guys youve all been excellent!


---
Message posted from http://www.ExcelForum.com/




Greg85374[_2_]

excel save AND concatenation problem
 
Thanks for the reply....the problem with putting quotes in the string
was too vague about...

ie..you put...
sStr = "The name of the book, ""The House on the Hill,"" was visible t
all"...


put suppose its a variable im calling on

ie...LpFileName....suppose ive an instance where it store the path of
file...how would i pute quotes around the output of the string ie....

LpFileName = app.path & range("f7")

now i want to call it
x = str(LpfileName)
now I WANT x to be "c:\whatever,1-2-04"
but it comes out as c:\whatever,1-2-04
without the quote

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

excel save AND concatenation problem
 
Greg,

Try

x = Chr(34) & CStr(Lpfilename) & Chr(34)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Greg85374 " wrote in message
...
Thanks for the reply....the problem with putting quotes in the string i
was too vague about...

ie..you put...
sStr = "The name of the book, ""The House on the Hill,"" was visible to
all"...


put suppose its a variable im calling on

ie...LpFileName....suppose ive an instance where it store the path of a
file...how would i pute quotes around the output of the string ie....

LpFileName = app.path & range("f7")

now i want to call it
x = str(LpfileName)
now I WANT x to be "c:\whatever,1-2-04"
but it comes out as c:\whatever,1-2-04
without the quotes


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

excel save AND concatenation problem
 
I can't think of a single instance where I needed to put quotes around a
string from a variable. When you provide a variable to an argument looking
for a string, that is what the argument is looking for - it doesn't need
quotes around it. the quotes are only used when you are building string
constants. (as you see, the quotes are delimiters - they are not part of
the string).

--
Regards,
Tom Ogilvy

"Greg85374 " wrote in message
...
Thanks for the reply....the problem with putting quotes in the string i
was too vague about...

ie..you put...
sStr = "The name of the book, ""The House on the Hill,"" was visible to
all"...


put suppose its a variable im calling on

ie...LpFileName....suppose ive an instance where it store the path of a
file...how would i pute quotes around the output of the string ie....

LpFileName = app.path & range("f7")

now i want to call it
x = str(LpfileName)
now I WANT x to be "c:\whatever,1-2-04"
but it comes out as c:\whatever,1-2-04
without the quotes


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

excel save AND concatenation problem
 
Bob answered you literal request, but to illustrate:

lpStr = Activeworkbook.Name
? lpStr
Book1
? workbooks(lpstr).Name
Book1
? workbooks(chr(34) & lpstr & chr(34)).Name

the last command gives an error because there is no workbook named "Book1"

--
Rgards,
Tom Ogilvy


"Bob Phillips" wrote in message
...
Greg,

Try

x = Chr(34) & CStr(Lpfilename) & Chr(34)

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Greg85374 " wrote in message
...
Thanks for the reply....the problem with putting quotes in the string i
was too vague about...

ie..you put...
sStr = "The name of the book, ""The House on the Hill,"" was visible to
all"...


put suppose its a variable im calling on

ie...LpFileName....suppose ive an instance where it store the path of a
file...how would i pute quotes around the output of the string ie....

LpFileName = app.path & range("f7")

now i want to call it
x = str(LpfileName)
now I WANT x to be "c:\whatever,1-2-04"
but it comes out as c:\whatever,1-2-04
without the quotes


---
Message posted from http://www.ExcelForum.com/







All times are GMT +1. The time now is 10:25 AM.

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