Click here to Skip to main content
16,018,637 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have written a macro that opens an excel template, does some calculations on it and then SaveAs "" it. Problem is while saving the file I am getting this notification - "
C#
Be careful! Parts of your document may include personal information that can't be removed by the Document Inspector.

Clicking OK renders a corrupt excel file while clicking cancel does not save the file at all.

Though at first I was saving it by simply giving path and file name (D:\folder1\file.xlsx), later I tried it with mentioning general information I found on net(
C#
Filename:="C:\Data\" & BookName, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
), but with no gain.

I am using Excel 2013.

This problem arose all of a sudden. Before the code gave perfect result.
Any idea what is this?

Thanks.

What I have tried:

I tried with
C#
Filename:="C:\Data\" & BookName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False


I even replaced xlNormal with 51 as I found but it still does not work.
Posted

1 solution

Now I am saving using the following way:


C#
Wbk.SaveAs Filename:="D:\folder\filename.xls", FileFormat:=56, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False


56 is for .xls format. Now the result workbook is opening without any fuss.
Phew..!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900