1

Topic: Saving of a file by a macro

Hello!
The macro creates a file, interposes tables, forms pivot tables and charts. Then saves and closes a file.
If to open the saved file a macro produces the message "the Error regarding contained in the book. To fulfill recovery attempt? If you trust a source from which the book is received, push button" Yes "." If to push on "Yes" instead of tables as ListObject and instead of pivot tables simple tables without formatting on all tabs are displayed, there are charts.
If to pause a macro in save point and to save manually the file opens normally.
Why so happens? How correctly to save?

2

Re: Saving of a file by a macro

Try - to appropriate on mind to the book a name and to close with saving.

3

Re: Saving of a file by a macro

Interesting that with the same code, but in other files with a macro which also create separate files, tables form, saves and closes, without problems files open.

4

Re: Saving of a file by a macro

Akina wrote:

Try - to appropriate on mind to the book a name and to close with saving.

Thisworkbook. Name = "ImjaFajla"

So it is impossible

5

Re: Saving of a file by a macro

Now manually I save, I close and then normally does not open. On what it is necessary to pay attention?

6

Re: Saving of a file by a macro

If to stop a macro, excel  as if what that transits completing processes still. If saves a macro, not  as if does not transit completing processes. And likely then from for it files do not open.

7

Re: Saving of a file by a macro

In general if to recover a file at discovery the drop down list is deleted.
Here the code of creation of the list

With Diapazon.Validation
.Delete
.Add Type: = xlValidateList, AlertStyle: = xlValidAlertStop, Operator: = xlBetween, Formula1: =>>> "Yes, Is not present" <<<
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

the drop down list on object ObjectList the Table Can it is necessary as that on another to set? I already  with this problem

8

Re: Saving of a file by a macro

Found. From for this code the file then normally does not open.

For i = 1 To MaksimalnoeKolichestvoDnej
1 = DljaSpiska1 and Format (DateAdd ("d", i - 1, NachaloOtscheta), "dd mmmm yyyy")
If i <> MaksimalnoeKolichestvoDnej Then of DljaSpiska1 = DljaSpiska1 and ","
Next i
Set the Range = TekushchijList.Range (Cells (NachalnajaStrokaVyvoda, the Column), Cells (KonechnajaStrokaVyvoda, the Column))
With Diapazon.Validation
.Delete
.Add Type: = xlValidateList, AlertStyle: = xlValidAlertStop, Operator: = xlBetween, Formula1: =>>> DljaSpiska1 <<<
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

It turns out in drop down list 60 of elements.
After formation by a macro and before saving at a column there is a drop down list. And if to save, close and then anew to open, the drop down list already is not present.
Generally the drop down list has restrictions?

9

Re: Saving of a file by a macro

ferzmikk wrote:

Generally the drop down list has restrictions?

yes. The length of a line of the formula formed by a macro should not exceed 255 characters (including commas).