VB code on different computers...

deevooneh
05-12-2008, 01:48 PM
I just finished designing a workbook with VB code and it works perfectly on my computer, however certain functions dont work on other computers. Is there a reason why this is?

The first one that doesnt work is...

Sheets("Sheet1").Visible = x1veryhidden


and the other is the Harlan Pull Function.....

Function pull(xref As String) As Variant
Dim xlapp As Object, xlwb As Workbook
Dim b As String, r As Range, c As Range, n As Long
n = InStrRev(xref, "\")
If n > 0 Then
If Mid(xref, n, 2) = "\[" Then
b = Left(xref, n)
n = InStr(n + 2, xref, "]") - n - 2
If n > 0 Then b = b & Mid(xref, Len(b) + 2, n)
Else
n = InStrRev(Len(xref), xref, "!")
If n > 0 Then b = Left(xref, n - 1)
End If
If Left(b, 1) = "'" Then b = Mid(b, 2)
On Error Resume Next
If n > 0 Then If Dir(b) = "" Then n = 0
Err.Clear
On Error GoTo 0
End If
If n <= 0 Then
pull = CVErr(xlErrRef)
Exit Function
End If
pull = Evaluate(xref)
If IsArray(pull) Then Exit Function
If CStr(pull) = CStr(CVErr(xlErrRef)) Then
On Error GoTo CleanUp
Set xlapp = CreateObject("Excel.Application")
Set xlwb = xlapp.Workbooks.Add
On Error Resume Next
n = InStr(InStr(1, xref, "]") + 1, xref, "!")
b = Mid(xref, 1, n)
Set r = xlwb.Sheets(1).Range(Mid(xref, n + 1))
If r Is Nothing Then
pull = xlapp.ExecuteExcel4Macro(xref)
Else
For Each c In r
c.Value = xlapp.ExecuteExcel4Macro(b & c.Address(1, 1, xlR1C1))
Next c
pull = r.Value
End If
CleanUp:
If Not xlwb Is Nothing Then xlwb.Close 0
If Not xlapp Is Nothing Then xlapp.Quit
Set xlapp = Nothing
End If
End Function



My other pieces of code seem to work fine. The error message i get on the other computer is "cannot find object or library". Any suggestions?

tinyjack
05-13-2008, 05:55 AM
What versions of Excel do the 2 machines have?

deevooneh
05-13-2008, 10:56 AM
They are both Running Office 2003 SP 3

tinyjack
05-19-2008, 03:31 AM
Sorry, for the late reply.

If you are running the same version of Excel on both machines, the .Visible command should not be causing you an issue. What is different about the 2 machines? I have had problems in the past with machines using different languages.


TJ

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum