Sometimes I add a passwrod to an Excel table created in my Fox Pro code using these lines of code.
WITH oExcel
.
.
.(some code removed)
.
.ActiveWorkbook.Password = "XXX"
.ActiveWindow.CLOSE(xlSaveChanges)
.APPLICATION.QUIT
ENDWITH
I want to use a password to protect the spreadsheet from being modified not being opened. I usually just record a macro and copy the code into Fox Pro and then try and figure out what needs to be changed from the copied VB code to make it work with Fox Pro. I am having lots of trouble with this one. I don't get and syntax errors anymore and the code runs but it just doesn't work. It does add a write protect password to the table.
This is where I am at:
.ActiveWorkbook.WritePassword = "XXX"
.ActiveWorkbook.ReadOnlyRecommended = True
(VB code for write password WriteResPassword, I took out the RES and it worked for Fox Pro)
Any suggestions?
John O'D
Here is the entire program so far:
#DEFINE True .T.
#DEFINE False .F.
#DEFINE xlSaveChanges 2
oExcel = CREATEOBJECT ("Excel.Application")
oExcel.VISIBLE = .T.
WITH oExcel
.DisplayAlerts = .F.
.Workbooks.OPEN ("Open my file.xls")
.ActiveWorkbook.WritePassword = "XXX"
.ActiveWorkbook.ReadOnlyRecommended = True
.ActiveWindow.CLOSE(xlSaveChanges)
.APPLICATION.QUIT
ENDWITH
WITH oExcel
.
.
.(some code removed)
.
.ActiveWorkbook.Password = "XXX"
.ActiveWindow.CLOSE(xlSaveChanges)
.APPLICATION.QUIT
ENDWITH
I want to use a password to protect the spreadsheet from being modified not being opened. I usually just record a macro and copy the code into Fox Pro and then try and figure out what needs to be changed from the copied VB code to make it work with Fox Pro. I am having lots of trouble with this one. I don't get and syntax errors anymore and the code runs but it just doesn't work. It does add a write protect password to the table.
This is where I am at:
.ActiveWorkbook.WritePassword = "XXX"
.ActiveWorkbook.ReadOnlyRecommended = True
(VB code for write password WriteResPassword, I took out the RES and it worked for Fox Pro)
Any suggestions?
John O'D
Here is the entire program so far:
#DEFINE True .T.
#DEFINE False .F.
#DEFINE xlSaveChanges 2
oExcel = CREATEOBJECT ("Excel.Application")
oExcel.VISIBLE = .T.
WITH oExcel
.DisplayAlerts = .F.
.Workbooks.OPEN ("Open my file.xls")
.ActiveWorkbook.WritePassword = "XXX"
.ActiveWorkbook.ReadOnlyRecommended = True
.ActiveWindow.CLOSE(xlSaveChanges)
.APPLICATION.QUIT
ENDWITH