I have an xlsm file that I cannot open on excel online. So I am trying to create a code that every time I close the xlsm file it saves the information to a xlsx file that I can access on excel online.
I have the following code:
Sub SaveAs()
Dim FName As String
Dim FPath As String
Dim NewBook As Workbook
FPath = "C:\Users\arichards\Dropbox\Documents\Income vs Expens"
FName = "Income vs Expense" & Format(Date, "ddmmyyyy") & ".xlsx"
Set NewBook = Workbooks.Add
ThisWorkbook.Sheets("DataSort").Copy Before:=NewBook.Sheets(1)
If Dir(FPath & "" & FName) <> "" Then
MsgBox "File " & FPath & "" & FName & " already exists"
Else
NewBook.SaveAs Filename:=FPath & "" & FName
End If
End Sub
My issue with this code is error on every run that I cannot save to file type and save dialog appears. I want it to save automatically in the back ground. Help please?
I have the following code:
Sub SaveAs()
Dim FName As String
Dim FPath As String
Dim NewBook As Workbook
FPath = "C:\Users\arichards\Dropbox\Documents\Income vs Expens"
FName = "Income vs Expense" & Format(Date, "ddmmyyyy") & ".xlsx"
Set NewBook = Workbooks.Add
ThisWorkbook.Sheets("DataSort").Copy Before:=NewBook.Sheets(1)
If Dir(FPath & "" & FName) <> "" Then
MsgBox "File " & FPath & "" & FName & " already exists"
Else
NewBook.SaveAs Filename:=FPath & "" & FName
End If
End Sub
My issue with this code is error on every run that I cannot save to file type and save dialog appears. I want it to save automatically in the back ground. Help please?