Hyperlink problem

G

Guest

Hi,
I'm trying to set up hyplerlink.address value the following vba code

Dim invoicespath As String
Dim invoicesshortpath As String

invoicespath = "c:\management\invoices\"
invoicesshortpath = "invoices\"

MkDir (invoicespath & CompanyName)
Me.Companydirectory.Hyperlink.TextToDisplay = "Click here"
Me.Companydirectory.Hyperlink.Address = "invoicesshortpath & CompanyName
end sub

but everytime I'm running the code I get the following error message:
run-time error '7980':
the hyperlinkaddress or hyperlinksubaddress property is read-only for this
hyperlink

I would appreciate a tip on how to solve this problem.
thanks in advance
 
G

Guest

Yasaf,

The follwing code has been tested and is functional

'****Code Start****
Private Sub Companydirectory_DblClick(Cancel As Integer)

Dim invoicespath As String

invoicespath = "c:\management\invoices\"

If FolderExists(invoicespath & CompanyName) = False Then
MkDir (invoicespath & CompanyName)
End If
Me.Companydirectory = "Click here#" & invoicespath & CompanyName & "#"

End Sub

Public Function FolderExists(ByVal PathName As String) As Boolean
'taken from 'Detect if connected to the network' post 20070222
Dim nAttr As Long
' Grab the attributes, test valid values for folder bit.
On Error GoTo NoFolder
nAttr = GetAttr(PathName)
If (nAttr And vbDirectory) = vbDirectory Then
FolderExists = True
End If
NoFolder:
End Function
'****Code End****

Daniel
 
G

Guest

Daniel,
Thank you.
--
Yasaf Burshan


Daniel said:
Yasaf,

The follwing code has been tested and is functional

'****Code Start****
Private Sub Companydirectory_DblClick(Cancel As Integer)

Dim invoicespath As String

invoicespath = "c:\management\invoices\"

If FolderExists(invoicespath & CompanyName) = False Then
MkDir (invoicespath & CompanyName)
End If
Me.Companydirectory = "Click here#" & invoicespath & CompanyName & "#"

End Sub

Public Function FolderExists(ByVal PathName As String) As Boolean
'taken from 'Detect if connected to the network' post 20070222
Dim nAttr As Long
' Grab the attributes, test valid values for folder bit.
On Error GoTo NoFolder
nAttr = GetAttr(PathName)
If (nAttr And vbDirectory) = vbDirectory Then
FolderExists = True
End If
NoFolder:
End Function
'****Code End****

Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top