我的代码是这样的
Sub 导入工资()
Set sh = ActiveSheet
With Workbooks.Open(myPath)
.Sheets(1).UsedRange.Offset(1).Copy sh.[b2]
.Close False
End With
End Sub 导入不成功.zip(22.82 KB, 下载次数: 0)
在网上搜到这段,但不会添加
Dim oWB As Workbook
Dim oPV As ProtectedViewWindow
Set oPV = Excel.Application.ActiveProtectedViewWindow
If oPV Is Nothing Then
Else
'如果是受保护视图,则允许编辑
With oPV
Set oWB = .Edit
End With
End If
点击文件名下载附件
Sub 导入某月表()
Dim conn As Object
Dim sql As String
Set conn = CreateObject("adodb.connection")
With Application.FileDialog(msoFileDialogFilePicker) '运行后出现标准的选择文件夹对话框
If .Show Then fn = .SelectedItems(1) Else Exit Sub '如选中则返回=-1 / 取消未选则返回=0
End With