【发布时间】:2016-04-04 10:34:01
【问题描述】:
在 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
有人可以看看我的代码并告诉我如何让它正常运行吗?
谢谢!
【问题讨论】: