excel save AND concatenation problem

  • Thread starter Thread starter Greg85374
  • Start date Start date
G

Greg85374

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!
 
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
 
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
 
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)
 
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).
 
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 said:
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)
 
Back
Top