Trying to coding VBA in a workbook (Start), vbaproject excel objects: thisworkbook to run the code when it opens.
Want to open workbook that can vary in name (ie: SOF 180530) and then go to worksheet (BAA), select the entire BAA worksheet and save file as a different format CSV (ie: SOFData.CSV)
Once the new file is created to reopen the file and be on the only worksheet SOFData. Want to turn off the pop notifications and override existing files if any.
At this time this is the code I have but get a Run-Time error '9 and for some reason it takes this workbook (start) and makes another file called (SOFData), eek:
'this line works
Thanks in advance
[/FONT][/COLOR][/LEFT]
Want to open workbook that can vary in name (ie: SOF 180530) and then go to worksheet (BAA), select the entire BAA worksheet and save file as a different format CSV (ie: SOFData.CSV)
Once the new file is created to reopen the file and be on the only worksheet SOFData. Want to turn off the pop notifications and override existing files if any.
At this time this is the code I have but get a Run-Time error '9 and for some reason it takes this workbook (start) and makes another file called (SOFData), eek:
'this line works
Code:
Private Sub Workbook_Open()
MsgBox "Hello and Welcome to the FAD Update and Back up Process click OK to PROCEED"
Dim wkb as workbook
Dim sht as worksheet
Set wkb = workbooks.open ("K:\CLC\FAD\*SOF????*.xlsx") 'this line appears to work as the file is in the background
Set sht = wkb.sheets ("BAA ").Copy 'the workbook is in the back ground but not on the right sheet
Thisworkbook =.Saveas filename:="[LEFT][COLOR=#222222][FONT=Verdana]K:\CLC\FAD\SOFData.csv", FileFormate:=x1CSVWindos
ActiveWindow.Close
Set wkb= Workbooks.Open("[LEFT][COLOR=#222222][FONT=Verdana]K:\CLC\FAD\SOFData.csv[/FONT][/COLOR]")
[/LEFT]
Dim wb as string
Dim sh as String
Dim Path as String
path = "[LEFT][COLOR=#222222][FONT=Verdana]K:\CLC\FAD\SOFData.csv[/FONT][/COLOR]"
[/LEFT]
wb="SOFData.csv"
sh="SOFData"
Sheets(sh).Active
End Sub
Thanks in advance
[/FONT][/COLOR][/LEFT]
Last edited by a moderator: