VBA:如何打开名称中包含 # 字符的文件? [英] VBA: Howto open a file, that has # -characters in it's name?

查看:57
本文介绍了VBA:如何打开名称中包含 # 字符的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个访问数据库前端,单击按钮后,某些文件会打开,并带有与之关联的软件.实现此目的的代码如下:

I have an access database front-end, and on a buttonclick, certain files are opening, with the software they are associated with. The code to achieve this is the following:

If (IsNull(Me.filepath)) Then Exit Sub
If (FileFolderExists(Me.filepath)) Then
    If (isFolder(Me.filepath)) Then
        Shell "explorer.exe " & Me.filepath, vbNormalFocus
    Else
        FollowHyperlink Me.filepath
    End If
End If

好吧,这一切都很好并且可以正常工作,但是如果文件名包含 # 符号,则文件将无法打开.不幸的是,情况确实如此:一些文件名如下所示:13_tamogatodontes##1911_201001.pdf

Well, this is all good and working, but the file won't open, if the filename contains # symbols. Wich is unfortunatly the case: Some of the filenames look like this: 13_tamogatodontes##1911_201001.pdf

我试图用谷歌找到一些答案,但在 msdn 上,没有找到任何有用的信息.有人知道如何解决这个问题吗?

I tried to find some answers with google, and on msdn, did not found any useful info. Does somebody know how to solve this problem?

推荐答案

您还需要将文件名括在引号中,例如:

You need to enclose your filename in quotes also, e.g:

Shell "explorer.exe " & "" & Me.filepath & "", vbNormalFocus

我不确定它是 2 还是 3 个双引号,但可以玩一下 :)

I'm not sure if it's 2 or 3 double quotes but have a play around : )

这篇关于VBA:如何打开名称中包含 # 字符的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆