我有一个短版本或DOS格式的路径(例如"C:/ DOCUME~1")并希望得到它的完整路径/长路径(例如"C:/ Documents And Settings").
我试过GetLongPathName api.有效.但是当处理unicode文件名时,它就会失败.
Private Declare Function GetLongPathName Lib "kernel32" Alias _
"GetLongPathNameA" (ByVal lpszShortPath As String, _
ByVal lpszLongPath As String, ByVal cchBuffer As Long) As Long
Run Code Online (Sandbox Code Playgroud)
我尝试使用别名GetLongPathNameW,但似乎什么都不做,因为BOTH Unicode和非Unicode文件名,总是返回0.在MSDN中,只有关于C/C++的GetLongPathNameW的文章,而不是任何用于VB/VBA的文章.我可能做错了吗?
这种情况有什么解决方案吗?我在Google和StackOverflow上花了好几个小时但却找不到.
问候,
使用早期绑定和Microsoft Scripting Runtime Library创建字典对象时,看起来有两个相同的类型名称用于同一事物:
Dim dict as Dictionary
Set dict = New Dictionary
Run Code Online (Sandbox Code Playgroud)
和
Dim dict as Scripting.Dictionary
Set dict = new Scripting.Dictionary
Run Code Online (Sandbox Code Playgroud)
似乎做同样的事情(至少到目前为止).
我看到了这个资源As Scripting.Dictionary使用的语法,我看到了这个(非常好的)资源使用的语法,但我没有看到任何地方的比较.关于字典的MSDN文档要么是文字笑话,要么与VBA没有明确相关.As Dictionary
我不明白为什么我应该做额外的打字只是为了让我的函数声明更加拥挤,如果我可以使用As Dictionary,但我已经了解到VBA中看起来像它们相同的一些东西实际上可以有微妙但显着的差异(Application.InputBoxvs .InputBox例如).
这些之间是否真的没有区别,或者我应该注意哪些微妙的差异?
我将变量声明为double,以便可以对其执行数学运算。
我试图确定何时按下取消按钮。
Dim thckmax As Double
thckmax = InputBox("What is the maximum nominal thickness?", "Enter Max Nominal Thickness Measurement")
If thckmax = 0 Then
GoTo Line3
End If
thckmin = InputBox("What is the minimum nominal thickness?", "Enter Min Nominal Thickness Measurement")
If thckmin = 0 Then
GoTo Line3
End If
thcknom = (thckmax + thckmin) / 2
Worksheets(1).Range("C" & cols + 2).Value = thcknom
.
.
.
Line3: ...
Run Code Online (Sandbox Code Playgroud)
我知道我用过GoTo。这是一个快速轻松的修复程序,用于启动和运行代码。
我得到运行时错误13类型不匹配。我也试过CDbl(...),StrPtr(...),IsEmpty(...)和,而不是将它们设置等于零我也曾尝试
If …Run Code Online (Sandbox Code Playgroud) 我输入开始日期和结束日期并执行从 Outlook 导出的代码。
Sub ExportFromOutlook()
Dim dteStart As Date
Dim dteEnd As Date
dteStart = InputBox("What is the start date?", "Export Outlook Calendar")
dteEnd = InputBox("What is the end date?", "Export Outlook Calendar")
Call GetCalData(dteStart, dteEnd)
End Sub
Run Code Online (Sandbox Code Playgroud)
我希望当我按下任何输入框上的“取消按钮”时退出子程序,而不是在 VBA 代码中出现错误来调试它。