在ms access 2013中,我有一个用户表单(frm_viewer),其中包含名为wbContent的Web浏览器控件。
我编写了以下代码来填充和显示本地PDF文件,但似乎无法使其正常运行。
我确实通过将控件的Control Source属性引用到同一表单上的文本框(即Control Source - > Base URL - > Expression Builder - > = [MyTextbox])来设法让它工作,但是我不想使用这种方法,我更喜欢使用变量动态填充它。
Private Sub lblBrowse_Click()
'declare file dialog with late binding ->
Dim fDialog As Object, strPath As String
Set fDialog = Application.FileDialog(3) 'msoFilePicker
'set parameters ->
Me.wbContent.ControlSource = ""
'initializing the file dialog ->
With fDialog
.AllowMultiSelect = False
.Filters.Clear '
.title = "Please select a file..."
'display the dialog box. If the .Show method returns True
'the user picked a file. If the .Show method returns False
'the user clicked Cancel.
If .show = True Then
strPath = .SelectedItems(1)
Debug.Print "SELECTED_FILE: " & strPath
'set source property to the string containing the full path ->
Me.wbContent.ControlSource = strPath
Me.wbContent.Requery
Else
End If
End With
End Sub
有人可以看看我的代码并告诉我如何让它正常运行吗?
谢谢!
答案 0 :(得分:2)