View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.scripting.vbscript
D. Pirate Roberts D. Pirate Roberts is offline
external usenet poster
 
Posts: 8
Default PasteSpecial: values and formats possible in vbs?

Thanks, Tom - that works perfectly! By the way, is there an online reference
guide that lists the PasteSpecial codes that can be used in this manner?


"Tom Ogilvy" wrote in message
...
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?