使用VBScript或CMD更改VBA脚本
我到处找了,没有找到解决问题的办法。 我需要的是使用VBscript(甚至CMD)更改VBA的一部分 我有这样的想法:使用VBScript或CMD更改VBA脚本,vba,vbscript,cmd,Vba,Vbscript,Cmd,我到处找了,没有找到解决问题的办法。 我需要的是使用VBscript(甚至CMD)更改VBA的一部分 我有这样的想法: Sub Test If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False NameColumn = Application.WorksheetFunction.Match("Names", Range(Cells(line, column), Cells(line,
Sub Test
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
NameColumn = Application.WorksheetFunction.Match("Names", Range(Cells(line, column), Cells(line, column + 30)), 0)
Cells(line, colum).Select
Selection.AutoFilter Field:=NameColumn, Criteria1:="=*ABC*", _
Operator:=xlAnd
Selection.End(xlDown).Select
If ActiveCell.Row < 1000 Then
Call Copy("ABC")
End If
SendEmail("ABC is done", emailaddress)
End Sub
我还有一个使用VBS运行VBA的代码:
Sub ExcelMacroExample()
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("C:\Documents\Example.xlsm")
xlApp.Run "RunMacro"
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
然而,我真的看不到这些脚本之间的联系,我也没有在互联网上找到关于这个问题的任何信息
有人知道如何使用VBS更改VBA代码的一部分吗?
使用VBS将是最好的方法,因为我正在运行的进程的其他部分。但是我会接受不同的答案。对
测试使用parametr如何,然后使用xlApp通过测试。运行:
xlApp.Run "Example.xlsm!Test", "ABC"
带参数的测试接头:
Sub Test(str As String)
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
NameColumn = Application.WorksheetFunction.Match("Names", Range(Cells(Line, Column), Cells(Line, Column + 30)), 0)
Cells(Line, colum).Select
Selection.AutoFilter Field:=NameColumn, Criteria1:="=*" & str & "*", _
Operator:=xlAnd
Selection.End(xlDown).Select
If ActiveCell.Row < 1000 Then
Call Copy(str)
End If
Call SendEmail(str & " is done", emailaddress)
End Sub
子测试(str作为字符串)
如果ActiveSheet.AutoFilterMode=True,则ActiveSheet.AutoFilterMode=False
NameColumn=Application.WorksheetFunction.Match(“名称”、范围(单元格(行、列)、单元格(行、列+30))、0)
单元格(线、柱)。选择
Selection.AutoFilter字段:=NameColumn,标准1:=“=*”&str&“*”_
运算符:=xlAnd
选择。结束(xlDown)。选择
如果ActiveCell.Row<1000,则
呼叫副本(str)
如果结束
呼叫SendEmail(str&“完成”,emailaddress)
端接头
Sub Test(str As String)
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
NameColumn = Application.WorksheetFunction.Match("Names", Range(Cells(Line, Column), Cells(Line, Column + 30)), 0)
Cells(Line, colum).Select
Selection.AutoFilter Field:=NameColumn, Criteria1:="=*" & str & "*", _
Operator:=xlAnd
Selection.End(xlDown).Select
If ActiveCell.Row < 1000 Then
Call Copy(str)
End If
Call SendEmail(str & " is done", emailaddress)
End Sub