Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access 使用web浏览器控件访问vba显示本地PDF文件_Ms Access_Vba - Fatal编程技术网

Ms access 使用web浏览器控件访问vba显示本地PDF文件

Ms access 使用web浏览器控件访问vba显示本地PDF文件,ms-access,vba,Ms Access,Vba,在ms access 2013中,我有一个用户表单(frm_查看器),其中包含一个名为wbContent的web浏览器控件 我编写了以下代码来填充和显示本地PDF文件,但似乎无法使其正常工作 我确实通过将控件的控件源属性引用到同一表单上的文本框(即,控件源->基本URL->表达式生成器->=[MyTextbox])使其工作,但我不想使用此方法,我更喜欢使用变量动态填充它 Private Sub lblBrowse_Click() 'declare file dialog with late b

在ms access 2013中,我有一个用户表单(frm_查看器),其中包含一个名为wbContent的web浏览器控件

我编写了以下代码来填充和显示本地PDF文件,但似乎无法使其正常工作

我确实通过将控件的控件源属性引用到同一表单上的文本框(即,控件源->基本URL->表达式生成器->=[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
有人能看一下我的代码,让我知道如何让它正常工作吗

谢谢

试试这个:

Me.wbContent.ControlSource = "='" & strPath & "'"

控制源需要是这样的字符串:=''

Legend!成功了。web控件源属性似乎与vba窗体中的其他典型窗体控件有很大不同。至少可以这么说,这是很微妙的!再次感谢