How to Lock the version of Excel File

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,524
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
Codebox asks:

codebox said:
I am a visual Foxpro Programer.

Visual foxpro can append data directly from .xls file(5/95 Workbook) into .dbf/table but It can not append from Excel 2007 or xlsx files.

So, keeping in view the above limitation of visual foxpro, I am giving samle excel 5/95 sheet to the user where they can put their data and upload in my application.

But my problem is that now most of the users have higher version installed in their system and whenever they save my excel it automatically gets converted in higher version, due to which the data is not added in Visual foxpro application.

Kinldy Guide that is there any technique by which though the user saves information in my excel file but it gets saved in 5/95 work book vesron only.

Please Guide
Regards

Question for you, Codebox... I assume that this is happening from your users doing a saveas?

Depending on the version of Excel you're using, you may need your end users to download a compatibility pack. Once you have that in place, dropping the following into the ThisWorkbook module of your project should work (I believe).

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim sSaveName As Variant
    
    Application.EnableEvents = False
    sSaveName = CStr(Application.GetSaveAsFilename)
    If sSaveName = "False" Then Exit Sub
    
    ThisWorkbook.SaveAs Filename:=sSaveName, FileFormat:=xlExcel9795
    
    Cancel = True
    Application.EnableEvents = True
End Sub
 
Top