mbmc.net
当前位置:首页 >> vBA打开指定工作簿 >>

vBA打开指定工作簿

以下代码可以实现输入工作表名称,按回车或点击确定后跳转至当前工作簿的该工作表 Sub 跳转()Dim sn As StringDim x As ...

sub nn() Workbooks.Open Filename:="C:\Documents and Settings\Excel\Example.xls " workbooks("Example.xls").worksheets(1) '对工作表1的引用就可以了 end sub 这些语句都不用去记,你通过录制宏就可以完全获得这种语句

workbooks.open "d:\我的数据表.xls" workbooks(workbooks.count).worksheets("Sheet1").activate '第一个引号内放完整路径及文件名,第二个引号内放工作表名

这个简单,在workbook_open事件里面写一句话就行了 Sheet1.Activate

Sheet1.Activate '激活sheet1,但是无效 你这个语句是激活的代码所有在工作簿的Sheet1,要激活新工作簿的Sheet1应该这样写: ActiveWorkbook.Sheets(1).Activate

改成这样: Sub try() Application.DisplayAlerts = False Dim mypath As String, svalue '定义变量 mypath = "C:\Users\Administrator\Desktop\1.xls" svalue = "C:\Users\Administrator\Desktop\2.xlsm" dim wkbk as object,wksht as object s...

代码: NewName = ActiveWorkBook.Path & "\" & ActiveSheet.Range("P5")OldName = "123.xls" '所谓的固定名称,这个需要自己指定WorkBooks.Open OldName '打开文件ActiveWorkBook.SaveAs NewName '另存为ActiveWorkBook.Close '关闭

懂点vba的看了下面的步骤就懂了。 1、Dim Wb As Workbook 2、 Dim Temp As String 3、 Temp = ThisWorkbook.Path & "\xxxx.xls" 4、Set Wb = GetObject(Temp) 5、 Wb.Windows(1).Visible = False 6、Wb.Sheets(1).cells(1,1)="xxxxx" 7、Wb.Wind...

参考下面的代码: Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Application.ScreenUpdating = False If MsgBox("需要操作的数据表是:EXCEL2003 格式,请选择:是!" & Chr(13) & "" & Chr(13) & "需要操作的数据表是:EXCEL2...

需要在VBE界面上引用Excel库才能打开Excel文件。最简单的语句如下所示: Sub test() Dim xcl As New Excel.Application Dim wbk As Workbook Set wbk = xcl.Workbooks.Open("E:\1.xls") xcl.Visible = True End Sub

网站首页 | 网站地图
All rights reserved Powered by www.mbmc.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com