excel 2007 macro/vb programing question
Here is an example:
'=============
ActiveWorkbook.SaveAs Filename:= _
sNewItem & "\Template ISO " & sSheetName & " Audit
mm.dd.yy.xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False,
WriteResPassword:="xxxx"
'=============
The "_" underscore after "ActiveWorkbook.SaveAs Filename:=" is a row
continuation symbol that lets you break lines into rows. There are
two underscores in this example.
( The symbols and < used to stop confusion of ("") quote usage.
The string sNewItem & "\Template ISO " & sSheetName & " Audit
mm.dd.yy.xlsx"<< means:
sNewItem is a variable (string) that contains the folder path
"\Template ISO " is simply text
sSheetName is a variable for the sheet name
" Audit mm.dd.yy.xlsx" is simply text (spaces intentional in this
case)
My example would create this string: (Assuming sNewItem is "C:
\Myfolder" and sSheetName is "MySheet")
C:\Myfolder\Template ISO MySheet Audit mm.dd.yy.xlsx
If you want to replace a variable with text simply use "" quotes
around the text.
"C:\Myfolder" & "\Template ISO " & "MySheet" & " Audit mm.dd.yy.xlsx"
will create the same result as my example.
C:\Myfolder\Template ISO MySheet Audit mm.dd.yy.xlsx
Also I show the use of password protecting the sheet
(WriteRespassword). Changing "WriteRespassword" to "Password" will
protect the workbook and not the sheet.
|