Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

vb/macros

Status
Not open for further replies.

bigb

Mechanical
Sep 17, 2002
12
US
bigb (Visitor) Jan 24, 2002
Hi

when I run my macro for excel in Visual basic I find this error:

Runtime error 1004

Method 'Range' of object' - Global' failed

I think the error is in this statement:

y = funct("abc", Range("abc"), 1)

--------------
The function has been defined as follows:

Declare Function funct Lib "hello.XLL" (ByVal sheetName As Variant, ByVal Range As Variant, ByVal lockFlag As Variant) As Long

Is range a predefined function which can be used in vb/macro
Range("abc") is supposed to calculate the range of the spread sheet "abc".

Could you help me fix this problem.
Thanks
bigb
 
Replies continue below

Recommended for you

Yes range is a predefined function. An easy way to check this is to write the word, position cursor right after the word and press F1 (help) If its a "key-word" then a help text will pop up.

Best regards

Morten
 
yes I found that range is a predefined function but the syntax seems to be wrong and I am not able to get the right one. can u please check and tell me
Thanx
 
when i run my macro for excel 2000 in microsoft visual basic i get run-time error '1004' Paste method of worksheet class failed and it specifically points me to ActiveSheet.Paste, please advise
 
keisha:
Please post as a new thread and include some of your code. The ActiveSheet.Paste method is a valid method, so there is some other problem with your code.

bigb:
The Range object should contain a reference to a specific cell or range of cells.
Range("A1")
Range("A1:C55")

Hope this helps...
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
 
This error usually is indicative of the macro getting confused about what spreadsheet it is working in. To test this close all spreadsheets. If you are in 2000 or XP do a CTRL-ALT-DEL and select processes. Make sure there are no EXCEL.EXE processes running. If there is kill it. Then try opening and running your macro.
 
I'm getting the following error.

"Run-time error '1004': Unable to set the CenterFooter property of the PageSetup class"

prntaSheet.Activate
prntaSheet.PageSetup.CenterFooter = "STYLE 1 : " & estsrcSheet.Cells(5, 1).Value & ", " & estsrcSheet.Cells(7, 1).Value & ", " & estsrcSheet.Cells(9, 1).Value & ", " & estsrcSheet.Cells(11, 1).Value & ", " & estsrcSheet.Cells(13, 1).Value
If estsrcSheet.Cells(5, 10).Value = "yes" Then
prntaSheet.PageSetup.CenterFooter = prntaSheet.PageSetup.CenterFooter & Chr(10) & "STYLE 2 : " & estsrcSheet.Cells(5, 2).Value & ", " & estsrcSheet.Cells(7, 2).Value & ", " & estsrcSheet.Cells(9, 2).Value & ", " & estsrcSheet.Cells(11, 2).Value & ", " & estsrcSheet.Cells(13, 2).Value
End If
If estsrcSheet.Cells(6, 10).Value = "yes" Then
prntaSheet.PageSetup.CenterFooter = prntaSheet.PageSetup.CenterFooter & Chr(10) & "STYLE 3 : " & estsrcSheet.Cells(5, 3).Value & ", " & estsrcSheet.Cells(7, 3).Value & ", " & estsrcSheet.Cells(9, 3).Value & ", " & estsrcSheet.Cells(11, 3).Value & ", " & estsrcSheet.Cells(13, 3).Value
End If
prntaSheet.Activate
'-------------------------
'ERROR OCURRS ON NEXT LINE
'-------------------------
prntaSheet.PageSetup.CenterFooter = prntaSheet.PageSetup.CenterFooter & Chr(10) & Chr(10) & "Bid Provided By : Art's Custom Cabinets, Inc. - (559) 562-2766"
prntaSheet.PageSetup.LeftFooter = estnumLabel.Caption

prntcSheet.Activate
With ActiveSheet.PageSetup
.CenterFooter = "STYLE 1 : " & estsrcSheet.Cells(5, 1).Value & ", " & estsrcSheet.Cells(7, 1).Value & ", " & estsrcSheet.Cells(9, 1).Value & ", " & estsrcSheet.Cells(11, 1).Value & ", " & estsrcSheet.Cells(13, 1).Value
If estsrcSheet.Cells(5, 10).Value = "yes" Then
.CenterFooter = ActiveSheet.PageSetup.CenterFooter & Chr(10) & "STYLE 2 : " & estsrcSheet.Cells(5, 2).Value & ", " & estsrcSheet.Cells(7, 2).Value & ", " & estsrcSheet.Cells(9, 2).Value & ", " & estsrcSheet.Cells(11, 2).Value & ", " & estsrcSheet.Cells(13, 2).Value
End If
If estsrcSheet.Cells(6, 10).Value = "yes" Then
.CenterFooter = ActiveSheet.PageSetup.CenterFooter & Chr(10) & "STYLE 3 : " & estsrcSheet.Cells(5, 3).Value & ", " & estsrcSheet.Cells(7, 3).Value & ", " & estsrcSheet.Cells(9, 3).Value & ", " & estsrcSheet.Cells(11, 3).Value & ", " & estsrcSheet.Cells(13, 3).Value
End If
'-------------------------
'ERROR OCURRS ON NEXT LINE
'-------------------------
.CenterFooter = ActiveSheet.PageSetup.CenterFooter & Chr(10) & Chr(10) & "Bid Provided By : Art's Custom Cabinets, Inc. - (559) 562-2766"
.LeftFooter = estnumLabel.Caption
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor