VBA不用打开excel文件就可读写单元格数据
更新时间:2024-01-23 04:36:01 阅读量: 教育文库 文档下载
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
正在阅读:
中水施工方法04-17
第七章相关与回归分析习题10-27
电大本科统考《计算机应用基础》选择题资料05-25
医院庆三八慰问信参考范文02-21
《儒林外史》读后感范文03-24
2004年9月月考(1600G)06-14
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 可读写
- 单元
- 不用
- 打开
- 文件
- 数据
- excel
- VBA