D
Daminc
I'm in the process of trying to trash a userform before turning it into
a add-in.
Originally, part of my code held:
Code:
--------------------
Select Case rngNetwork
Case 1
Set wrkbkUrl = Workbooks.Open(Filename:="P:\VBA training\Excel templates for Network stats\1 Network.xls")
Sheets(Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec", "TempAnalysis", "Yearly summary")).Select
Cells.Replace What:="1st Network", Replacement:=strNetwork1, LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False
Sheets("Jan").Select
Range("C3").Select
savewrkbkname = Application.GetSaveAsFilename(wrkbkname, fileFilter:="Excel Files (*.xls), *.xls")
ActiveWorkbook.SaveAs Filename:=savewrkbkname
--------------------
which did the job but one of the senarios I created was:
What if the user cancelled the save before the save was completed?
This highlighted a bug that saved the '1 Network.xls' as 'False'
instead of cancelling the save.
In order to try and remedy this I changed the code to:
Code:
--------------------
If (Application.GetSaveAsFilename(wrkbkname, fileFilter:="Excel Files (*.xls), *.xls")) Then
savewrkbkname = Application.GetSaveAsFilename(wrkbkname, fileFilter:="Excel Files (*.xls), *.xls")
Else: ActiveWorkbook.Close
End If
--------------------
However, this gave a 'Type Mismatch' error
Does anyone have an insight to what's going wrong please?
a add-in.
Originally, part of my code held:
Code:
--------------------
Select Case rngNetwork
Case 1
Set wrkbkUrl = Workbooks.Open(Filename:="P:\VBA training\Excel templates for Network stats\1 Network.xls")
Sheets(Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec", "TempAnalysis", "Yearly summary")).Select
Cells.Replace What:="1st Network", Replacement:=strNetwork1, LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False
Sheets("Jan").Select
Range("C3").Select
savewrkbkname = Application.GetSaveAsFilename(wrkbkname, fileFilter:="Excel Files (*.xls), *.xls")
ActiveWorkbook.SaveAs Filename:=savewrkbkname
--------------------
which did the job but one of the senarios I created was:
What if the user cancelled the save before the save was completed?
This highlighted a bug that saved the '1 Network.xls' as 'False'
instead of cancelling the save.
In order to try and remedy this I changed the code to:
Code:
--------------------
If (Application.GetSaveAsFilename(wrkbkname, fileFilter:="Excel Files (*.xls), *.xls")) Then
savewrkbkname = Application.GetSaveAsFilename(wrkbkname, fileFilter:="Excel Files (*.xls), *.xls")
Else: ActiveWorkbook.Close
End If
--------------------
However, this gave a 'Type Mismatch' error
Does anyone have an insight to what's going wrong please?