VBA不用打开excel文件就可读写单元格数据

2019-08-29 21:46

VBA不用打开excel文件就可读写单元格数据 使用WPS时编的

在第一个工作薄添加CommandButton3按钮添加代码如下:

Private Sub CommandButton3_Click() Dim Wb As Workbook

Set Wb = GetObject(\项目设计\\操作表\\联系2.xls\ Wb.Sheets(1).Range(\

Workbooks(1).Sheets(1).Range(\ Dim str As String

str = Wb.Sheets(1).Range(\ MsgBox (str)

Wb.Sheets(1).Visible = xlSheetVisible Wb.Save Wb.Close True Set Wb = Nothing

End Sub

在第一个工作薄“Workbooks(1)”添加按钮

CommandButton1,添加如下代码:

Private Sub CommandButton1_Click()

Dim Wb As Workbooks

fileToOpen = Application.GetOpenFilename(\

If fileToOpen <> False Then

Workbooks.Open Filename:=fileToOpen, AddToMru:=True MsgBox (Workbooks(2).Name)

‘使用按钮CommandButton1打开第二个工作薄,因此是Workbooks(2)

Windows(Workbooks(2).Name).Visible = True '取消隐藏,因文件已打开因此使用windows()函数

If Workbooks(2).ReadOnlyRecommended = True Then Workbooks(2).ReadOnlyRecommended = False '取消只读 End If Else End If

End Sub


VBA不用打开excel文件就可读写单元格数据.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:美国大学教师的评价机制及其启示

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: