ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Protected VBA and 2003 (https://www.excelbanter.com/excel-discussion-misc-queries/89816-protected-vba-2003-a.html)

MikeFullam

Protected VBA and 2003
 
I hope some one can help me with a problem I have with sharing files. We are
migrating to Excel 2003 and there is an incompatibility problem with locked
VBA files that are shared. To get round this I thought I could unlock the
file in VBA using send keys , then save and close the file in an early
version of Excel, there by making the file universally acceptable, but
although I can run as two separate macros I cant combine them into one
operation, Can any one help me? below is the code I have created.

Sub UnlockVBA()
With Application
..SendKeys "%{F11}", True
..SendKeys "%Te", True
..SendKeys "fred", True
..SendKeys "~", True
..SendKeys "~", True
..SendKeys "%{F11}", True
End With
End Sub

Sub SaveOldStyle()
Dim fn As Variant
fn = Application.GetSaveAsFilename("MyFileName.xls", _
"Excel files,*.xls", 1, "Select your folder and filename")
If TypeName(fn) = "Boolean" Then Exit Sub
ActiveWorkbook.SaveAs fn, FileFormat:=xlExcel9795
End Sub


Jim Rech

Protected VBA and 2003
 
Perhaps...

Sub UnlockVBA()
With Application
.SendKeys "%{F11}", True
.SendKeys "%Te", True
.SendKeys "fred", True
.SendKeys "~", True
.SendKeys "~", True
.SendKeys "%{F11}", True
End With
Application.OnTime DateAdd("s", 0, Now), "SaveOldStyle"
End Sub


--
Jim
"MikeFullam" wrote in message
...
|I hope some one can help me with a problem I have with sharing files. We
are
| migrating to Excel 2003 and there is an incompatibility problem with
locked
| VBA files that are shared. To get round this I thought I could unlock the
| file in VBA using send keys , then save and close the file in an early
| version of Excel, there by making the file universally acceptable, but
| although I can run as two separate macros I can't combine them into one
| operation, Can any one help me? below is the code I have created.
|
| Sub UnlockVBA()
| With Application
| .SendKeys "%{F11}", True
| .SendKeys "%Te", True
| .SendKeys "fred", True
| .SendKeys "~", True
| .SendKeys "~", True
| .SendKeys "%{F11}", True
| End With
| End Sub
|
| Sub SaveOldStyle()
| Dim fn As Variant
| fn = Application.GetSaveAsFilename("MyFileName.xls", _
| "Excel files,*.xls", 1, "Select your folder and filename")
| If TypeName(fn) = "Boolean" Then Exit Sub
| ActiveWorkbook.SaveAs fn, FileFormat:=xlExcel9795
| End Sub
|




All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com