Almost there!
A slight modification to suite my needs made the code look like this:
[vba]Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("V_50300").Formula = ThisWorkbook.FullName
End Sub[/vba]
When I run below sub
[vba]
Sub SaveFile()
Dim wb As Workbook
Set wb = ActiveWorkbook
If Range("V_10300") = True Then
If UCase(wb.FullName) = UCase(Range("V_50100").Value) Then
MsgBox (UCase(Range("KUNDPOST_NAMN").Value) & " skapas!")
ActiveWorkbook.SaveAs Range("V_50200").Value
Workbooks.Open wb.FullName
wb.Save
Else
wb.Save
End If
Else
MsgBox (UCase("Cannot save - name is missing!"))
'The user has to write something in EXP_1010 which will be a part of the new name for the workbook
Range("EXP_1010").Select
End If
Set wb = Nothing
End Sub
[/vba]
I don't get the correct name in cell V_50300 immediately but will have to save manually once. This is a big improvement since I won't have to close and reopen the workbook!
So, only thing now is to get above sub to save the correct file once more, I think. I have tried different methods but above sub will still not understand it is the newly created workbook named Range("V_50200").Value I want to save.
My idea is to add something like :
[vba]
If Workbook called Range("V_50200").Value is open Then
Save Workbook called Range("V_50200").Value
' which is in fact the very same workbook
[/vba]
This way we won't have to involve the problem with the active workbook and V_50300 will say the correct filename every time Sub SaveFile has run.
In case this is possible I believe this thread can come to a closure. Is it possible?