By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 2,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

Runtime Error/OpenDialog box

P: n/a
DD
Can anyone tell me why this code is crashing in a Runtime enviroment
This is code from MS NorthWind

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current logo. If the user selects a file
' display it in the image control.
Dim FileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Logo Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
FileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = FileName
Me![CompanyName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You cannot use the FileDialog object from the Office library in the runtime
envirnoment.

Instead, use the API call from this link:
http://www.mvps.org/access/api/api0001.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"DD" <da**********@bigpond.com.au> wrote in message
news:14**************************@posting.google.c om...
Can anyone tell me why this code is crashing in a Runtime enviroment
This is code from MS NorthWind

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current logo. If the user selects a file
' display it in the image control.
Dim FileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Logo Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .Show
If (result <> 0) Then
FileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = FileName
Me![CompanyName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.