我有一个excel VB模块,我想添加到新打开的工作簿中。
我在静态excel工作簿中有以下代码,用于根据文件名打开变量工作簿。
Sub OpenYest_File()
Dim FilePath As String, Rng As Range, FName As String, Ext As String, wb As Workbook, FileDate As String
YDate = Date - 1
FileDate = Format(YDate, "yyyymmdd")
MsgBox FileDate
'set variables
FilePath = "J:\Prepay\Pay Go Appt & GE Site\Data Analyst\Data Analyst Use\Raw Info\Gas Meter Exchanges\"
Ext = "*" & FileDate & ".tsv"
FName = Dir(FilePath & Ext)
'Set Rng = Sheets("Raw Data").Range("A1").End(xlDown)
Do While FName <> ""
Set wb = Workbooks.Open(Filename:=FilePath & FName, Local:=True)
FName = Dir
Loop
End Sub
我还有另外一个我写过的模块,但是想把它添加到新打开的excel工作簿中。
有没有办法在打开时将VB代码插入工作簿?
感谢您的帮助。