Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code not executing

I'm wondering if anybody has come accros a problem similar to this.


I have a workook which when it opens begins an automatic updat
process. When the process is complete the workbook is to close.
However, in the code in the close event it won't executet he code.
There are no errors the code just doesn't perform.

For example the one line of code is Me.Save. The workbook doe
nothing. Now if I insert a Cancel = True, then abort the code, an
then close the workbook manually when I step through the cod
everything works perfectly.


I use a OLE object and I'm wondering if that could be the cause.
However, I use the same object in other books without issue. Ha
anybody ever seen this problem and it's cause

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Code not executing

Hi
you may show the code in your workbook_open event and in your
workbook_beforeclose event

--
Regards
Frank Kabel
Frankfurt, Germany


I'm wondering if anybody has come accros a problem similar to this.


I have a workook which when it opens begins an automatic update
process. When the process is complete the workbook is to close.
However, in the code in the close event it won't executet he code.
There are no errors the code just doesn't perform.

For example the one line of code is Me.Save. The workbook does
nothing. Now if I insert a Cancel = True, then abort the code, and
then close the workbook manually when I step through the code
everything works perfectly.


I use a OLE object and I'm wondering if that could be the cause.
However, I use the same object in other books without issue. Has
anybody ever seen this problem and it's cause?


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code not executing

As per request. Here are the Open and Close events for the workbook.

Private Sub Workbook_BeforeClose(Cancel As Boolean)

' Initialize all global variables
If Not gblnGlobalVariablesInit Then Cal
Initialize_Global_Variables

' Local Variables
Dim intWkbsOpen As Integer
Dim wkb As Workbook

' Step 1 : Only proceed if logged in user is the current workboo
owner
If gstrPCLoginUser < UCase(Range("ad_wi_Owner").Offset(0, 2)
Then
Me.Saved = True
Cancel = True
Exit Sub
End If

' Step 2 : Update set file access status to ReadWrite
If Me.ReadOnly Then
Me.Saved = True
Call wkscmd_ToggleReadOnly
End If

' Step 3 : Save workbook
Me.Save

' Step 3 : Determine how to close
intWkbsOpen = Application.Workbooks.Count
For Each wkb In Application.Workbooks
If wkb.Name = "Personal.xls" Then intWkbsOpen = intWkbsOpen
1
Next wkb
If intWkbsOpen = 1 Then Application.Quit


End Sub


Private Sub Workbook_Open()

' Initialize all global variables
If Not gblnGlobalVariablesInit Then Cal
Initialize_Global_Variables

' Local Variables


' Step 1 : Always reset file access to ReadOnly on opening
If Not Me.ReadOnly Then
Me.Saved = True
Me.ChangeFileAccess Mode:=xlReadOnly
End If

' Step 2 : Always rehide all sheets
Call wkscmd_ToggleSheetVis(True)

' Step 3 : Initiate auto processing
Call PerformAutoContinue

End Sub


I'm not having any luck reducing the file size to less than the 1M
limit imposed on attachments. So if you need more code I can U2U wit
the actual workbook

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code not executing

I have had a similar error. It had to do with my script opening a secon
workbook (and activating it), but I still referred to the firs
workbook (which contained the script) as the ActiveWorkbook.

I don't know if this is similar to the problem you are experiencing
but maybe it helps you...

--
Message posted from http://www.ExcelForum.com

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
QUERY & HELP: so slow executing VBA code... :S John Keith Excel Worksheet Functions 3 February 13th 06 03:47 PM
WorkbookOpen code not executing properly SK Excel Programming 0 April 21st 04 04:09 PM
(trying again...) code stops executing Mark Kubicki Excel Programming 0 December 4th 03 02:00 PM
VBA code stops executing Mark Kubicki Excel Programming 0 December 3rd 03 06:47 PM
Code Changes Not Executing Justin[_8_] Excel Programming 1 October 24th 03 02:31 AM


All times are GMT +1. The time now is 06:36 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"