S
Shawn Ferrier
Good afternoon, all.
First, thanks for all the great past posts. They've been a wealth of
information for me while trying to figure out how to use OWC for the
first time.
That being the case, I've encountered one odd issue that I haven't
been able to find any reference to. Here is the situation. I have an
ASP page that has three Spreadsheet objects. The actual number is
dynamic, since it is based on how many CSV files are found, but let's
stick with three. All three objects have an identically defined
Spreadsheet_Initialize sub defined. The first of the three does not
execute when I load the page initially - I have to click Refresh in
order for it to fire. The other two workbooks have no problem.
Here is the code in question:
----------
<A NAME="Report2"></A><CENTER><H2>General User Information</H2>
<P><H3>This report is an output of primary user
information.</H3><P><OBJECT ID=Spreadsheet2
CLASSID=CLSID:0002E551-0000-0000-C000-000000000046
STYLE="WIDTH:49%;HEIGHT:359"></OBJECT></CENTER>
<SCRIPT LANGUAGE=VBScript>
Option Explicit
Sub Spreadsheet2_Initialize()
Dim objProtection
Dim objUsedRange
Dim objWorksheet
Spreadsheet2.CSVURL = "General User Information.txt"
Spreadsheet2.ActiveWorkbook.Worksheets("Sheet2").Delete
Spreadsheet2.ActiveWorkbook.Worksheets("Sheet3").Delete
For Each objWorksheet in Spreadsheet2.Worksheets
Set objUsedRange = objWorksheet.UsedRange
objUsedRange.Columns.AutoFit
objUsedRange.Locked = True
Set objProtection = objWorksheet.Protection
With objProtection
.Enabled = True
End With
Next
Set objWorksheet = Nothing
Set objUsedRange = Nothing
Set objProtection = Nothing
End Sub
</SCRIPT>
----------
Does anyone see anything terribly wrong with this? You may wonder
about things like why am I looping through worksheets when there is
clearly only one since I've deleted the other two. This piece of code
is created dynamically - in some cases, there are other worksheets.
There would be other code inserted that would be calling LoadText on
some other file.
Much obliged,
Shawn
sferrier at gmail dot com
First, thanks for all the great past posts. They've been a wealth of
information for me while trying to figure out how to use OWC for the
first time.
That being the case, I've encountered one odd issue that I haven't
been able to find any reference to. Here is the situation. I have an
ASP page that has three Spreadsheet objects. The actual number is
dynamic, since it is based on how many CSV files are found, but let's
stick with three. All three objects have an identically defined
Spreadsheet_Initialize sub defined. The first of the three does not
execute when I load the page initially - I have to click Refresh in
order for it to fire. The other two workbooks have no problem.
Here is the code in question:
----------
<A NAME="Report2"></A><CENTER><H2>General User Information</H2>
<P><H3>This report is an output of primary user
information.</H3><P><OBJECT ID=Spreadsheet2
CLASSID=CLSID:0002E551-0000-0000-C000-000000000046
STYLE="WIDTH:49%;HEIGHT:359"></OBJECT></CENTER>
<SCRIPT LANGUAGE=VBScript>
Option Explicit
Sub Spreadsheet2_Initialize()
Dim objProtection
Dim objUsedRange
Dim objWorksheet
Spreadsheet2.CSVURL = "General User Information.txt"
Spreadsheet2.ActiveWorkbook.Worksheets("Sheet2").Delete
Spreadsheet2.ActiveWorkbook.Worksheets("Sheet3").Delete
For Each objWorksheet in Spreadsheet2.Worksheets
Set objUsedRange = objWorksheet.UsedRange
objUsedRange.Columns.AutoFit
objUsedRange.Locked = True
Set objProtection = objWorksheet.Protection
With objProtection
.Enabled = True
End With
Next
Set objWorksheet = Nothing
Set objUsedRange = Nothing
Set objProtection = Nothing
End Sub
</SCRIPT>
----------
Does anyone see anything terribly wrong with this? You may wonder
about things like why am I looping through worksheets when there is
clearly only one since I've deleted the other two. This piece of code
is created dynamically - in some cases, there are other worksheets.
There would be other code inserted that would be calling LoadText on
some other file.
Much obliged,
Shawn
sferrier at gmail dot com