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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel PasteSpecial with VBScript

Status
Not open for further replies.

edcharleslynn

Programmer
Jul 20, 2004
11
GB
Hello, does anyone know what the correct syntax is to use PasteSpecial with VBScript rather than VBA.

Thanks very much

Ed
 
What have you so far ?
The syntax is the same as VBA but don't use named arguments and replace the xlPasteXXXX constants by their value.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the reply PHV. Im just copying a sheet, activating another and trying to just paste the values onto the second one.

Code:
excel.Workbooks(sourcefile).Sheets("Swinton").Activate
With excel.activeSheet.Cells
	excel.Cells.Select
	excel.selection.Copy
End with

excel.Workbooks(motempfile).Sheets("Swinton").Activate
With excel.activeSheet.Cells
	excel.Cells.Select
	excel.selection.PasteSpecial 
End with

would i do something like:

excel.selection.PasteSpecial Values,None,False,False ?

Thanks
 
Something like this ?
Const xlPasteValues = -4163 '(&HFFFFEFBD)
Const xlPasteSpecialOperationNone = -4142 '(&HFFFFEFD2)
excel.Selection.PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, False, False

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank you very much, that works great. I dont fully understand the values you have used, do you know of any sites/articles i could use for reference. Perhaps that list the names and their values?

Thanks again for your help
 
The reason i ask is because i need to make a change to a Validation also, which when changing requires named arguments, for example:

Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
' xlBetween, Formula1:="=$I$2:$I$19"

Thanks
 
In Excel, when in VBE (Alt-F11), open the Object browser window (F2).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top