Solved How do I set Web Browser Control to a default file? (1 Viewer)

Sampoline

Member
Local time
Today, 12:27
Joined
Oct 19, 2020
Messages
161
I have a web browser control (wbFile) that will display a file on a form. The control source of the WBC is to a text field (txtFileLocation) that will contain the file location. I have a button (cmdBrowse) that is used as a browse function to open file dialog.

I have created what I wanted. Except I'm a little unsure on how I can make a file default on form open. Here is my 'on click' event for my button:

Code:
Private Sub cmdBrowse_Click()

    Dim file As FileDialog
    Set file = Application.FileDialog(msoFileDialogFilePicker)
    
    file.AllowMultiSelect = False
    
    If file.Show Then
        Me.txtFileLocation = file.SelectedItems.Item(1)
    End If

End Sub

How can I make a file (of my choice) a default, so that the file is already displayed when the form is opened?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:27
Joined
Oct 29, 2018
Messages
21,453
Hi. You didn't post your code for displaying the user selected file in your browser control. All you have to do is use the same code, but specify the default file, in the Open event of your form.
 

Sampoline

Member
Local time
Today, 12:27
Joined
Oct 19, 2020
Messages
161
Hi. You didn't post your code for displaying the user selected file in your browser control. All you have to do is use the same code, but specify the default file, in the Open event of your form.
Hello there, in the web browser control I added =[txtFileLocation] in the base URL. So what exactly am I changing here and in the form's open event?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:27
Joined
Oct 29, 2018
Messages
21,453
Hello there, in the web browser control I added =[txtFileLocation] in the base URL. So what exactly am I changing here and in the form's open event?
In that case, in your txtFileLocation control, try entering the default file location in the Default Value property.
 

Users who are viewing this thread

Top Bottom