Excel VBA Workbook_Open Application or Object defined error -
i have workbook run macro once opened.
private sub workbook_open()     getpaymenttypes     createhyperlinks paymenttype, paymenttypelocation  end sub both subs getpaymenttypes , createhyperlinks run fine (they in module of own) application defined or object defined error when workbook_open runs. 
the error occurs in createhyperlinks:
sub createhyperlinks(paymenttype, paymenttypelocation)      ' below errors worksheets(1) or active sheet, workbook_open()     activesheet             .hyperlinks.add anchor:=.range(paymenttypelocation), _             address:="", _             subaddress:="", _             screentip:="go 80 byte population guide for: " & paymenttype, _             texttodisplay:=paymenttype     end end sub i must referencing 'activesheet' hyperlinks wrong, cannot seem solve this. many assistance received.
the variable paymenttype defined in class module. private paymenttype string
there function populates array of paymenttypes. assign relevant 1 paymenttype , call createhyperlinks passing paymenttype it.
so agreed in comments variables not passed workbook_open.
remedy problem set variables public.
example: public paymenttype string
actually there nothing wrong making them public. variable having public property set , subroutines can use them (not 1 sets it).
sometimes need set them public if writing more complicated subroutine. anyway, if sensitive data privacy should not use excel files data carriers.
a little guide variable scope: http://www.excel-easy.com/vba/examples/variable-scope.html
Comments
Post a Comment