473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access to Excel PasteSpecial Values

Hi Guys,
Hope you can help
I am trying to interact with excel and I am having a problem with
pastespecial values

I am trying
excelobj.activesheet.pastespecial paste:=xlvalues
it keeps erroring on the paste:=xlvalues, does any one know the
correct syntax to use??

and any help on how to return the last row on a spreadsheet would help
as well

Thanks and regards,

RichPu
Nov 13 '05 #1
3 16236
If your project does not have a reference to the Excel Object Model, then Acces
can't resolve Excel's named constants, like xlvalues.

You have two choices: 1) Make a reference to the Excel Object Model, or 2)
change the constants to their long equivalents. (For example, xlvalues = -4163,
which I used the immediate window in Excel)

Another technique (if you do't want to follow the advice of 1) is to declare
your constants in your procedure, like so:

Const xlvalues As Long = -4163

Then you don't need to change your original code.
Nov 13 '05 #2
I don't know if this is "correct" syntax, but it is currently working for
me.

' Excel Constants
Public Const xlAscending As Integer = 1
Public Const xlSortLabels As Integer = 2
Public Const xlTopToBottom As Integer = 1
Public Const xlAll As Integer = -4104
Public Const xlValues As Integer = -4163
Public Const xlDown As Integer = -4121
Public Const xlLeft As Integer = -4131
Public Const xlThin As Integer = 1
Public Const xlCenter As Integer = -4108
Public Const xlBottom As Integer = -4107
Public Const xlTop As Integer = -4160
Public Const xlRight As Integer = -4152
Public Const xlAutomatic As Integer = -4105
Public Const xlSolid As Integer = 1
Public Const xlMedium As Integer = -4138
Public Const xlDouble As Integer = -4119
Public Const xlThick As Integer = 4
Public Const xlEdgeBottom As Integer = 9
Public Const xlDatabase As Integer = 1
Public Const xlPageField As Integer = 3
Public Const xlColumnField As Integer = 2
Public Const xlDataField As Integer = 4
Public Const xlRowField As Integer = 1
Public Const xlEdgeRight As Integer = 10

Private Sub DoSomeExcelStuff()
Dim XL As Object, XLA As Object
Set XL = GetObject(SSFile)
Set XLA = XL.Application
With XLA
.Range("A1").copy
.Range("A4:A" & .Range("B4").end(xlDown).Row).pastespecial
Paste:=xlAll
End With
End Sub

It copies the formula in A1, to all cells from A4 to the end of the data in
B. It's late binding, needs no reference. You, of course, only need the
contstants that you are actually using.

HTH,
Randy Harris
"Rich Pu" <ri****@yahoo.com> wrote in message
news:ba**************************@posting.google.c om...
Hi Guys,
Hope you can help
I am trying to interact with excel and I am having a problem with
pastespecial values

I am trying
excelobj.activesheet.pastespecial paste:=xlvalues
it keeps erroring on the paste:=xlvalues, does any one know the
correct syntax to use??

and any help on how to return the last row on a spreadsheet would help
as well

Thanks and regards,

RichPu

Nov 13 '05 #3
Thanks for the help

RichPu
"Randy Harris" <ra***@SpamFree.com> wrote in message
news:ie***************@newssvr33.news.prodigy.com. ..
I don't know if this is "correct" syntax, but it is currently working for
me.

' Excel Constants
Public Const xlAscending As Integer = 1
Public Const xlSortLabels As Integer = 2
Public Const xlTopToBottom As Integer = 1
Public Const xlAll As Integer = -4104
Public Const xlValues As Integer = -4163
Public Const xlDown As Integer = -4121
Public Const xlLeft As Integer = -4131
Public Const xlThin As Integer = 1
Public Const xlCenter As Integer = -4108
Public Const xlBottom As Integer = -4107
Public Const xlTop As Integer = -4160
Public Const xlRight As Integer = -4152
Public Const xlAutomatic As Integer = -4105
Public Const xlSolid As Integer = 1
Public Const xlMedium As Integer = -4138
Public Const xlDouble As Integer = -4119
Public Const xlThick As Integer = 4
Public Const xlEdgeBottom As Integer = 9
Public Const xlDatabase As Integer = 1
Public Const xlPageField As Integer = 3
Public Const xlColumnField As Integer = 2
Public Const xlDataField As Integer = 4
Public Const xlRowField As Integer = 1
Public Const xlEdgeRight As Integer = 10

Private Sub DoSomeExcelStuff()
Dim XL As Object, XLA As Object
Set XL = GetObject(SSFile)
Set XLA = XL.Application
With XLA
.Range("A1").copy
.Range("A4:A" & .Range("B4").end(xlDown).Row).pastespecial
Paste:=xlAll
End With
End Sub

It copies the formula in A1, to all cells from A4 to the end of the data in B. It's late binding, needs no reference. You, of course, only need the
contstants that you are actually using.

HTH,
Randy Harris
"Rich Pu" <ri****@yahoo.com> wrote in message
news:ba**************************@posting.google.c om...
Hi Guys,
Hope you can help
I am trying to interact with excel and I am having a problem with
pastespecial values

I am trying
excelobj.activesheet.pastespecial paste:=xlvalues
it keeps erroring on the paste:=xlvalues, does any one know the
correct syntax to use??

and any help on how to return the last row on a spreadsheet would help
as well

Thanks and regards,

RichPu


Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MikeZcg | last post by:
I keep getting this error : PasteSpecial method of the worksheet class faild with this code : Public Sub runtest() Dim f1 As Form1 Dim xl As New Excel.Application() Dim dataFile As New...
4
by: Lisa | last post by:
Hi - I'm able to open excel workbooks and word documents, but I can't seem to copy excel charts, named ranges, etc. to a word document. Anyone know of good reference material in this area? What...
1
by: adrian | last post by:
hello! i have a problem in pasting the content of a cell into another. i have tried it with the following code: excel = createobject ("excel.application") with excel .range...
0
by: meditcakepbgt | last post by:
Hi this is my code 1st Case I try to import very long excel range, into a powerpoint slide (kindda doing automating stuff). And i noticed that this "Copypicture" can only capture the range...
5
by: sotsigo | last post by:
Hi there, I am a quite unexperienced VB user and I am trying to do some simple operations in excel. I am presenting my existing problematic code below. I am trying to copy/paste a range of...
0
by: Nicholas Dreyer | last post by:
Operating System: Microsoft Windows Version 5.1 (Build 2600.xpsp_sp2_gdr.050301-1519 : Service Pack 2) Visual Basic: MIcrosoft Visual Basic 6.3 Version 9972 VBA: Retail 6.4.9972 Forms3:...
4
by: keithsimpson3973 | last post by:
Hi. I am trying build an array in vb applications for excel. I am posting the code for what I am trying to write. Any help would be appreciated greatly.. Sheets("C16-M-001").Select ...
0
by: shantanu | last post by:
I am trying to convert a macro code to c# that will copy the values of a column and paste to anather through paste special. Everything is working fine but the transpose meathod to paste the column...
3
by: asciiletters | last post by:
I have a spreadsheet with cells that use randbetween(). At the bottom of each column there is a sum() cell for these cells. I made a macro that refreshes the values until a column's total is within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.