Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 24
Default Cancel of text box leaves sheet unprotected

Macro I am using unprotects my sheet so that it can run then uses a msg box
followed by an info box entry as a component of the save name for a new file.

Problem happens when user tells the msg box no, OR cancels out of the info
box, Sheet is left unprotected. I have not been able to resolve myself or
piece together code from your answers to other questions to stop this problem.

Code I have is:

Sub saveit()
ActiveSheet.Unprotect Password:="'"
Sheets("dms wizard").Select
ActiveSheet.Unprotect Password:="'"

response = MsgBox("Generate New System DMS?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter System Name", "Path Will Be L:\E&T Pillar\KCS
Library\DMS\<Dept Name\<System Name.DMS")
If Name = "" Then End
ActiveWorkbook.SaveAs Filename:="L:\E&T Pillar\KCS Library\DMS\" &
Range("C8").Value & "\" & Name & ".DMS.xls"

Can you help me reprotect in the event of a "no" or a cancel?
--
THANKS!

Steve
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Cancel of text box leaves sheet unprotected

Sub seeIfThishelps()
If MsgBox("Generate New System DMS?", _
vbYesNoCancel + vbQuestion, "Save As") < vbYes Then
MsgBox "This is what happens if user clicks no or cancel"
Exit Sub
End If
MsgBox "This is what happens if user clicks yes"

End Sub

"Steve_n_KC" wrote:

Macro I am using unprotects my sheet so that it can run then uses a msg box
followed by an info box entry as a component of the save name for a new file.

Problem happens when user tells the msg box no, OR cancels out of the info
box, Sheet is left unprotected. I have not been able to resolve myself or
piece together code from your answers to other questions to stop this problem.

Code I have is:

Sub saveit()
ActiveSheet.Unprotect Password:="'"
Sheets("dms wizard").Select
ActiveSheet.Unprotect Password:="'"

response = MsgBox("Generate New System DMS?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter System Name", "Path Will Be L:\E&T Pillar\KCS
Library\DMS\<Dept Name\<System Name.DMS")
If Name = "" Then End
ActiveWorkbook.SaveAs Filename:="L:\E&T Pillar\KCS Library\DMS\" &
Range("C8").Value & "\" & Name & ".DMS.xls"

Can you help me reprotect in the event of a "no" or a cancel?
--
THANKS!

Steve

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 24
Default Cancel of text box leaves sheet unprotected

Thanks Mike! Code works great but I'm not quite smart enough to be able to
get it to do what I need.
If I add it in addition to existing code, it didn't work on NO/Cancel
selection of my Msg Box, but did give me a 2nd Msg Box that and I was able to
make it work if No/Cancel was chosen for that box.
I've tried about 50 variations of blending the 2 codes together with the
varying degrees of negative results...
The closest I got was with this:
sub saveit()
ActiveSheet.Unprotect Password:="'"
Sheets("dms wizard").Select
ActiveSheet.Unprotect Password:="'"

response = MsgBox("Generate New System DMS?" _
, vbYesNoCancel, "Save As")
If response = 6 Then
Name = InputBox("Enter System Name", "Path Will Be L:\E&T Pillar\KCS
Library\DMS\<Dept Name\<System Name.DMS")
If Name = "" Then End
If MsgBox("Generate New System DMS?", _
vbYesNoCancel + vbQuestion, "Save As") < vbYes Then
MsgBox "You Have Chosen to NOT Generate DMS-Make any desired Changes and
Select Green Button When Ready"
ActiveSheet.Protect Password:="'", DrawingObjects:=True, Contents:=True,
Scenarios:=True
Exit Sub
End If

Which as I said worked on the 2nd box but not the 1st. Any Ideas on what I
need to do to get my "Input box save" from Yes and an immediate Protect Sheet
and exit sub from No, Cancel or X'ing out???

--
THANKS AGAIN for the response!

Steve


"Mike" wrote:

Sub seeIfThishelps()
If MsgBox("Generate New System DMS?", _
vbYesNoCancel + vbQuestion, "Save As") < vbYes Then
MsgBox "This is what happens if user clicks no or cancel"
Exit Sub
End If
MsgBox "This is what happens if user clicks yes"

End Sub

"Steve_n_KC" wrote:

Macro I am using unprotects my sheet so that it can run then uses a msg box
followed by an info box entry as a component of the save name for a new file.

Problem happens when user tells the msg box no, OR cancels out of the info
box, Sheet is left unprotected. I have not been able to resolve myself or
piece together code from your answers to other questions to stop this problem.

Code I have is:

Sub saveit()
ActiveSheet.Unprotect Password:="'"
Sheets("dms wizard").Select
ActiveSheet.Unprotect Password:="'"

response = MsgBox("Generate New System DMS?" _
, vbYesNo, "Save As")
If response = 6 Then
Name = InputBox("Enter System Name", "Path Will Be L:\E&T Pillar\KCS
Library\DMS\<Dept Name\<System Name.DMS")
If Name = "" Then End
ActiveWorkbook.SaveAs Filename:="L:\E&T Pillar\KCS Library\DMS\" &
Range("C8").Value & "\" & Name & ".DMS.xls"

Can you help me reprotect in the event of a "no" or a cancel?
--
THANKS!

Steve

Reply
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
unprotect a sheet that appears to be unprotected already TamsinL Excel Worksheet Functions 3 December 9th 06 10:28 AM
Text File Import leaves a blank row after each line R Kapoor Setting up and Configuration of Excel 0 January 8th 06 02:07 PM
Protected sheet to unprotected sheet [email protected] Excel Worksheet Functions 2 October 26th 05 05:30 PM
Tab key don't work in unprotected cells in a protected sheet Chad Excel Discussion (Misc queries) 0 August 16th 05 02:00 AM
My sheet is unprotected, but I can't format cells. Paul Excel Discussion (Misc queries) 2 February 9th 05 11:20 PM


All times are GMT +1. The time now is 12:14 AM.

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"