LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Protecting VBA (Excel) code

I have a model that uses VBA to save the file. The variables are
dimmed as appropriate and then I use this code to compile the save
filename:

DSNDirectory = "\\" & Range("appserver") & "\" & Range("appprogdir") &
"\utils\"
DSNFilename = Range("dsnfile")

Then I use
Application.DisplayAlerts = False
ChDir DSNDirectory
ActiveWorkbook.SaveAs FileName:=DSNDirectory + DSNFilename, _
FileFormat:=xlTextMSDOS, CreateBackup:=False
DisplayAlerts = True

and this saves the particular worksheet as a text file.
And this all works until I lock the project for viewing and protect it
with a password. Once that's done running the macro that contains the
code described above results in an error 1004 method 'SaveAs' of
object '_workbook' failed. I can't debug it because it's locked, and
if I unlock it the code works. So I can't work out what's wrong!
Does anyone have any ideas?
Thanks in advance
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Protecting Code in Visual Basic Editor (Excel 2003) Johnny S. NH Excel Worksheet Functions 1 August 30th 08 07:26 AM
Protecting VB Code Sanjay[_2_] Excel Programming 1 April 20th 07 05:32 PM
Protecting the code Harald Staff Excel Programming 0 August 31st 04 02:58 PM
Protecting buttons with VB code rather than protecting sheets/books? StargateFanFromWork Excel Programming 2 July 16th 04 04:03 PM
Hiding/Protecting vb code in excel IanStrange Excel Programming 1 November 10th 03 10:37 AM


All times are GMT +1. The time now is 12:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"