Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I escape the colon character? 1

Status
Not open for further replies.

MPAD

Programmer
Sep 25, 2002
4
GB
1) I am writing some VBScript (not VBA) code that creates and manipulates an Excel Workbook.


2) All works well except that some Excel methods use a character sequence of colon folowed by equals ":=" to distinguish options, for example-

With objExcel.ActiveSheet
.Move after:=Worksheets(objExcel.Worksheets.Count)
.Name = newSheetName
End With

or

objExcel.Active.Workbook.Names.Add Name:="Finance"


3) These ":=" methods do not work because VBScript alwasy treats the COLON as a LINE SEPARATOR and so the syntax is considered incorrect and the code fails.



4) Is there any way that the Colon can be escaped so that it does not mean line separator or can anyone think of another way to achieve the ":=" that the Excel method(s) need


Rgds - M
 
Hello MPAD,

Vbs only use position variables, so try do it like this.
Code:
With objExcel.ActiveSheet
   .Move(,Worksheets(objExcel.Worksheets.Count)
   .Name = newSheetName
End With
and
Code:
objExcel.Active.Workbook.Names.Add("Finance" )
regards - tsuji
 
erratum

Miss out a closing parenthesis
Code:
.Move(,Worksheets(objExcel.Worksheets.Count))

-tsuji
 
Tsuji

Tried positional param for the worksheet name method and it worked perfectly - many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top