jpimbert / VBAToolKit

Toolkit for quality development with Excel VBA
150 stars 46 forks source link

File format : xla behaving strangely #14

Closed lucas-v closed 10 years ago

lucas-v commented 11 years ago

When saving a workbook with the xlAddIn (18) file format, the wb.FileFormat property has the value 56 instead of 18.

Code to reproduce

Dim wb As Workbook
Set wb = vtkCreateExcelWorkbook()
wb.SaveAs "C:\Any\Path\Will\Do\xxxx.xla", FileFormat:=xlAddIn

Debug.Print "xla = " & xlAddIn
Debug.Print "actual = " & wb.FileFormat

vtkCloseAndKillWorkbook wb

Results are :

xla = 18
actual = 56

Notes

The behaviour for other file formats, such as :

is normal.

jpimbert commented 11 years ago

The effective format of the created .xla is .xls file (fileFormet=56). Plus, this file is not opened by Excel2003 (bad file format). I think it's because .xla extension and fileFormat parameter are not matching each other. I had to manually recreate the .xla file to get a true AddIn Excel 2003 file (with extension .xla and fileFormat=18).

Perhaps, set the .IsAddIn property of this workbook to True will solve both problems :

lucas-v commented 10 years ago

Setting the IsAddIn property to True actually solves the problem of the format. :+1: Does the following code gives a file openable by Excel 2003 — if you have it around ?

Dim wb As Workbook
Set wb = vtkCreateExcelWorkbook()
wb.IsAddin = True
wb.SaveAs "C:\Any\Path\Will\Do\xxxx.xla", FileFormat:=xlAddIn

Debug.Print "xla = " & xlAddIn
Debug.Print "actual = " & wb.FileFormat

' vtkCloseAndKillWorkbook wb
jpimbert commented 10 years ago

Je n'ai pas de 2003 sous la main ; j'essaie avec la dernière version de VBAToolKit cette semaine chez le client.

jpimbert commented 10 years ago

The generated XLA is now recognized by Excel : the format is good. But there is a crash because the name of the project should be "VBAToolKit". It doesn't work with "VBAToolKit_2003"

lucas-v commented 10 years ago

Does renaming the project name manually change anything ? Otherwise an optional "VBProjectName overrride" field must be added in the configuration objects.

jpimbert commented 10 years ago

Manually renaming the project seems a good workaround: no crash when I did it. A manual operation is not a good practice. The issue will be closed when a complete fix will be done. The simplest way seems to add an optional "projectName" attribute to the XML configuration element.

lucas-v commented 10 years ago

Good thing we have a working workaround. I'll fix the issue soon.

jpimbert commented 10 years ago

It's the Story#24 in the IceScrum Backlog. A lot of stories not to be estimated; the next sprint can't be planned.