View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.scripting.vbscript
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default PasteSpecial: values and formats possible in vbs?

XLBook.Worksheets("Sheet1").Select
XLBook.Worksheets("Sheet1").Range("A1").Copy
XLBook.Worksheets("Sheet1").Range("B1").PasteSpeci al 12

--
regards,
Tom Ogilvy


"D. Pirate Roberts" wrote in message
...
I use the following code in vbs to copy and paste data from one Excel cell
to another:

XLBook.Worksheets("Sheet1").Select
XLBook.Worksheets("Sheet1").Range("A1").Copy
XLBook.Worksheets("Sheet1").Range("B1").PasteSpeci al

My code above does a regular paste, but I need to do a paste special that
only pastes values and number formats. I've created a macro in Excel that
does this and the vba code for it is:

Range("A1").Select
Selection.Copy
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

However, the vba code above does not work in vbs. It throws an Expceted
Statement error at the first colon (:) in the PasteSpecial line. Does

anyone
know how I can do this in vbs?