Hello ALL,
I've done tons researching online and have yet to find an example of what I'm trying to do. Below you will find a macro I'm running to export specifics of the current active workbook.
How do I add to this to copy or add vba code to the new file its creating into its "ThisWorkBook" section? The code below works perfect with saving the exact file and parts I need but is lacking the code in the new file.
Any help or direction is greatly appreciated. (Not cross posted)
''''''''export files
'''xlsx file
Dim filename2 As String
filename2 = Range("data_psu_name")
Application.EnableEvents = False
Application.DisplayAlerts = False
Sheets(Array("Project Setup Sheet", "Drop Downs")).Copy
Sheets("Drop Downs").Select
Range("A1:G50").ClearContents
Sheets("Project Setup Sheet").Select
Worksheets("Drop Downs").Visible = False
ActiveWorkbook.SaveAs filename2, FileFormat:=52, CreateBackup:=False
ActiveWorkbook.Close
Application.EnableEvents = True
Application.DisplayAlerts = True
Here is the VBA I would like to add to the new file during my export. This needs to be added to the "ThisWorkBook" section.
Private Sub Workbook_Open()
Dim my_wb As Workbook
Dim file_path As String
Dim filename8 As String
filename8 = "Library_Temp"
Application.EnableEvents = False
Application.DisplayAlerts = False
file_path = "S:\BLANK\BLANK\BLANK\BLANK\BLANK\BLANK\Library.xlsm"
Set my_wb = Workbooks.Open(FileName:=file_path, ReadOnly:=True)
ActiveWorkbook.SaveAs filename8, FileFormat:=52, CreateBackup:=False
ActiveWindow.Visible = False
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub
Bookmarks