Link to home
Start Free TrialLog in
Avatar of VBAlearner2010
VBAlearner2010Flag for France

asked on

Application.DisplayAlerts in Office 2010

Could you please help me out in replacement code for the below code to work in Office 2010. I get error in Application.DisplayAlerts = False
Sub save_as(NOM_FICHIER_SOURCE, CHEMIN_FICHIER_DEST, NOM_FICHIER_DEST)

    Windows(NOM_FICHIER_SOURCE).Activate
    
    Application.DisplayAlerts = False
        
    ActiveWorkbook.SaveAs FileName:=CHEMIN_FICHIER_DEST & NOM_FICHIER_DEST, _
    FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
    
    ActiveWorkbook.Close
    

End Sub

Open in new window

Avatar of redmondb
redmondb
Flag of Afghanistan image

Hi, VBAlearner2010.

What error are you getting?

Thanks,
Brian.
Avatar of VBAlearner2010

ASKER

Hi Redmondb,

The error is "Method or Data member not found"

Thank you
Avatar of mustang83
mustang83

i think the problem is with Windows(NOM_FICHIER_SOURCE).Activate

What are you attempting to do? run activation and then save a file?
HI mustang83:

Its a big code flow for my to understand clearly. But i need to debug it..

I understood a little now.. I think there is not file for it run the code further.

I am working on a development environment where i dont have the reference file. It can be checked only with the user who uses the application. I just need to debug the code if it will work with Office 2010 after it has been migrated from 2007.

So hope this code should work on the actual environment.

Am i right?
VBAlearner2010.

Can you confirm that the error is actually happening on the SaveAs line?

(The code runs OK for me, but I don't think it's as simple as NOM_FICHIER_SOURCE not existing - that would give a subscript error (as would an invalid output file name/path).)

Regards,
Brian.
VBAlearner2010,

Silly question - you are running this in Excel aren't you?! It's just that "Application.DisplayAlerts = False" will give just that error in, for example, Access.

Regards,
Brian.
Hello redmond,

The error happens in Line 5 in Application.Displayalerts

Yeah this code is runnning in Excel.....
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Experts,

I apologize for being not responsive. I was not in office since there was a public holiday from Friday here... I would check and revert back.

Thank you all for your support and help....
Solved
Nice one, Rory. When run in Excel, why would the object qualified be needed?
To be honest I'm slightly surprised that worked! Normally, you would only need full qualification if another referenced library has the same object and appears higher in the reference priority, but you can't set another reference higher than Excel in Excel. Perhaps a variable named Application had been set.
Dont know but it worked.... :)
Thanks, Rory. (Every worried that you're starting to think like Excel?!)
Every day. :)