Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default The Run-Time Error 1004 That Wouldn't DIE

I am slowly going mad trying to figure out what has gotten into this
particular workbook. I have used similar code numerous times in the past,
but for some reason this time it JUST... WON'T... WORK! I don't know why!

Everytime it hits the last line, VBA bleats like a sheered sheep about how
the target cell is protected. But its not. The targeted workbook comes
unprotected from a vendor. Even if it was protected, I've tried multiple
ways to make it not be protected.

<---snip----
'Open file for Stage 1 processing and file conversion
Workbooks.Open FileName:=FilePath & "\Travel.xls"
'Windows("Travel.xls").Activate
Workbooks("Travel.xls").Activate
EnginesOffline
ShieldsDown
Defenseless
Select Case Worksheets(1).Range("R1").Value
Case "1" Or "2" Or "3"
Response = MsgBox("Stage ONE part " &
Worksheets(1).Range("R1").Value & " has already been run on this file!" &
Chr(13) & _
"It is recommended that you rebuild the file from scratch,
unless you have already made changes." _
& Chr(13) & "Do you wish to rebuild the file?", vbYesNo,
"Incomplete File Cycle Detected!")
If Response = vbYes Then
FileCopy DestinationFile, SourceFile 'Replace file from backup
Else
MsgBox "Travel Bill Automation Halted by user " &
CurrentUserName, vbOKOnly, "Program Halt!"
Exit Sub
End If
Case Else
MsgBox "Stage ONE now commencing on this file", vbOKOnly,
"Processing..." 'Continue
End Select
Workbooks("Travel.xls").Unprotect
Workbooks("Travel.xls").Sheets(1).Cells(1, 18).FormulaR1C1 = "1"
<-----Snip-----

Any suggestions? Is there a known issue with random unprotect failures? To
rule out my custom subroutines, here's what they do:

EnginesOffline - just shuts off updating;
ShieldsDown - shuts off protection to every sheet in the active workbook;
Defenseless - I made this up specifically to overcome this obstacle; it
calls a subroutine that unlocks every cell on every worksheet in the active
workbook.)

This may be another one of those "Blatent Idiotic Overlooking of the
Obvious" moments, and I'd be glad to know why!

Sincerely,
Damian Carrillo
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default The Run-Time Error 1004 That Wouldn't DIE

post the Defenseless code

Tim

"Damian Carrillo" wrote in
message ...
I am slowly going mad trying to figure out what has gotten into this
particular workbook. I have used similar code numerous times in the
past,
but for some reason this time it JUST... WON'T... WORK! I don't
know why!

Everytime it hits the last line, VBA bleats like a sheered sheep
about how
the target cell is protected. But its not. The targeted workbook
comes
unprotected from a vendor. Even if it was protected, I've tried
multiple
ways to make it not be protected.

<---snip----
'Open file for Stage 1 processing and file conversion
Workbooks.Open FileName:=FilePath & "\Travel.xls"
'Windows("Travel.xls").Activate
Workbooks("Travel.xls").Activate
EnginesOffline
ShieldsDown
Defenseless
Select Case Worksheets(1).Range("R1").Value
Case "1" Or "2" Or "3"
Response = MsgBox("Stage ONE part " &
Worksheets(1).Range("R1").Value & " has already been run on this
file!" &
Chr(13) & _
"It is recommended that you rebuild the file from
scratch,
unless you have already made changes." _
& Chr(13) & "Do you wish to rebuild the file?", vbYesNo,
"Incomplete File Cycle Detected!")
If Response = vbYes Then
FileCopy DestinationFile, SourceFile 'Replace file
from backup
Else
MsgBox "Travel Bill Automation Halted by user " &
CurrentUserName, vbOKOnly, "Program Halt!"
Exit Sub
End If
Case Else
MsgBox "Stage ONE now commencing on this file", vbOKOnly,
"Processing..." 'Continue
End Select
Workbooks("Travel.xls").Unprotect
Workbooks("Travel.xls").Sheets(1).Cells(1, 18).FormulaR1C1 = "1"
<-----Snip-----

Any suggestions? Is there a known issue with random unprotect
failures? To
rule out my custom subroutines, here's what they do:

EnginesOffline - just shuts off updating;
ShieldsDown - shuts off protection to every sheet in the active
workbook;
Defenseless - I made this up specifically to overcome this obstacle;
it
calls a subroutine that unlocks every cell on every worksheet in the
active
workbook.)

This may be another one of those "Blatent Idiotic Overlooking of the
Obvious" moments, and I'd be glad to know why!

Sincerely,
Damian Carrillo



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
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM
Run time Error 1004 Rich[_16_] Excel Programming 1 September 25th 04 11:41 PM


All times are GMT +1. The time now is 08:22 AM.

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

About Us

"It's about Microsoft Excel"