MsgBoxes Warnings

tuktuk

Well-known Member
Joined
Nov 13, 2006
Messages
856
for some reason i recieve msgbox asking if i'd like to save the following file when i run this code listed below.

would my setwarning stop this? what cahgnes are needed to have them save without the msgboses to pop up?

Code:
Private Sub SaveExportGenericOB()
Const FILE_PATH As String = "G:\Path\"
Dim strFullPath As String
strFullPath = FILE_PATH

DoCmd.SetWarnings False
Call DeleteXLSReport

Set objXl = CreateObject("Excel.Application")
With objXl.Application
.Visible = False
'This is the file to run the code on
.Workbooks.Open "G:\ PricingExportCURRENT.xls"
'This is the file that contains the macros
.Workbooks.Open "G: \CalcSummaryCreator.xls"
'Set the file to run the macro on as active
.Workbooks("PricingExportCURRENT.xls").Activate
'Call the macro
.Run "CalcSummaryCreator.xls!combo"
'Save the newly altered file
'.ActiveWorkbook.SaveAs (strFullPath & "PhaseTWOFlatBandPricingExport")
.ActiveWorkbook.SaveAs (strFullPath & "PhaseTWOFB")
.Quit
End With

Call DeleteXLSCURRENT
DoCmd.SetWarnings True

Set objXl = Nothing
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Will_B

Board Regular
Joined
Mar 4, 2009
Messages
79
In the Excel macro "CalcSummaryCreator.xls!combo", do you have a SetWarnings = False at the end? How about DeleteXLSReport and DeleteXLSCURRENT? If they do, your warning messages are being turned back on before you return to the procedure in question.

There may be reasons against changing any warnings settings in these other procedures, so the simplest solution I think is to add to your procedure a "SetWarnings = False" statement after each call made to another procedure.
 
Upvote 0

boblarson

MrExcel MVP
Joined
Nov 14, 2008
Messages
1,964
In the Excel macro "CalcSummaryCreator.xls!combo", do you have a SetWarnings = False at the end? How about DeleteXLSReport and DeleteXLSCURRENT? If they do, your warning messages are being turned back on before you return to the procedure in question.
That should say DoCmd.SetWarnings TRUE (not false) which would turn them back on.
There may be reasons against changing any warnings settings in these other procedures, so the simplest solution I think is to add to your procedure a "SetWarnings = False" statement after each call made to another procedure.
This could be dangerous if you lose track of where you are with them. Also, whenever using SetWarnings, each procedure that uses them should have an Error Handler and the first line in the Error Handler should be
DoCmd.SetWarnings True
to reset them in case something "glitches" before the normal reset can be run.
 
Upvote 0

boblarson

MrExcel MVP
Joined
Nov 14, 2008
Messages
1,964
I believe you are trying to save to an invalid file name too:

.ActiveWorkbook.SaveAs (strFullPath & "PhaseTWOFB")

Should be

.ActiveWorkbook.SaveAs (strFullPath & "PhaseTWOFB.xls")

or
.ActiveWorkbook.SaveAs (strFullPath & "PhaseTWOFB.xlsx")

depending on the version.
 
Upvote 0

Forum statistics

Threads
1,191,192
Messages
5,985,218
Members
439,948
Latest member
Xearo96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top