excel - VB.NET 中的 VBA 等效项
问题描述
我有一个在 excel 中工作的 VBA 模块,当我将其转换为 VB.net 时,我收到错误“UNC 路径的格式应为 \\server\share。”
VBA Excel模块1:
Global MyFolder As String
Global MyFile As Variant
Global eRow As Long
Global Crow As Long
Public Sub Browsing()
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
MyFolder = .SelectedItems(1) & "\"
Err.Clear
End With
MyFile = Dir(MyFolder & "\", vbReadOnly)
End Sub
转换后的 VB.net 代码模块 1
Imports System.IO
Imports Excel = Microsoft.Office.Interop.Excel
Module Module1
Public MyFolder As String
Public MyFile As VariantType
Public eRow As Long
Public Crow As Long
Public Sub Browsing()
Dim xl As New Excel.Application
With xl.Application.FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show()
MyFolder = .SelectedItems(1) & "\"
Err.Clear()
End With
**MyFile = Dir(MyFolder & "\", FileAttribute.ReadOnly)**
End Sub
End Module
错误:“UNC 路径的格式应为 \\server\share。”
感谢你的帮助
感谢和问候
莫赫布·拉比
解决方案
推荐阅读
- html - 设置为绝对时,href 按钮不起作用
- laravel - 根据与 Laravel 的关系使用 where
- javascript - 成功 import-jdl 后,JHipster 实体菜单为空
- python - 使用 matplotlib 或 seaborn 的多列线图
- c# - 如何触发按钮 C#
- ldap - 将 Opendj 从 2.6.4 升级到 3.5.3 以用于复制服务器
- python - 在模板中使用 for 循环显示多个动态对象
- angular - 使用 data-toggle 和 data-target 仅折叠通过 Angular 中的 Ng-For 部署的一组项目中的一项
- python - 如何将座位标记为每部电影已占用?
- python - 如何将整数大小和指针声明从 C++ 转换为 Python?