Can anyone help me? I'm using this code in a dialog box to allow a user to select a file, a hyperlink to that file is then stored in a cell.
This works without a hitch in Excel 2007. On another machine running 2010 it crashes the entire program once you click OK.
It runs from double clicking the cell where the link is to be placed.
Is there something obvious I'm overlooking, or some daft quirk with 2010 where this code would be expected to crash? This is something that I need to roll out across a number of users who will be using various versions of Excel, I'm absolutely snookered if it won't work on 2010.
Code:
Private Sub CommandButton1_Click()
'file select dialog
Set mb = Workbooks(ActiveWorkbook.Name)
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
Application.FileDialog(msoFileDialogOpen).Title = "Select nomination form"
Application.FileDialog(msoFileDialogOpen).InitialFileName = mb.Path & "\Nominations Received\"
Application.FileDialog(msoFileDialogOpen).Filters.Clear
intChoice = Application.FileDialog(msoFileDialogOpen).Show
' if file selected, run code. else close dialog
If intChoice <> 0 Then
'store selected file in textbox
TextBox1.Value = Application.FileDialog(msoFileDialogOpen).SelectedItems(1)
End If
End Sub
Private Sub CommandButton2_Click()
Set s = Workbooks(ActiveWorkbook.Name).Sheets(ActiveSheet.Name)
r = ActiveCell.Row
C = ActiveCell.Column
s.Cells(r, C).Hyperlinks.Add Anchor:=Selection, Address:=TextBox1.Value, TextToDisplay:="Link"
Unload Me
End Sub
This works without a hitch in Excel 2007. On another machine running 2010 it crashes the entire program once you click OK.
It runs from double clicking the cell where the link is to be placed.
Is there something obvious I'm overlooking, or some daft quirk with 2010 where this code would be expected to crash? This is something that I need to roll out across a number of users who will be using various versions of Excel, I'm absolutely snookered if it won't work on 2010.