473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

VB Scripts does not work on all workstations

1
I added this code to a an ASP page to print a gridview in Microsoft Excel. This page is a weekly work schedule for our company's intranet. The code works on a majority(80%) of the workstations in our business. On those machines that stop in mid script. The excel object is opened and visible; however the script stops executing at the line:
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML <----- Script stops executing at this point


The whole code:
Sub exportbutton_onclick
Const xlCellTypeLastCell = 11
dim sHTML, oExcel, oBook, LastRowWithData, Row
Dim ExcelLastCell, LastRow
If Err.Number > 0 Then
Call ErrorProc
End If

sHTML = document.all.item("dgWeekly_Plan").outerhtml
set oExcel = CreateObject("Excel.Application")
set oBook = oExcel.Workbooks.Add
oExcel.Visible = true
oExcel.UserControl = true
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML <----- Script stops executing at this point

oBook.HTMLProject.Refreshdocument

oExcel.ActiveWorkBook.ActiveSheet.Range("A2").Enti reColumn.Hidden = True
oExcel.ActiveWorkBook.ActiveSheet.Range("H2").Enti reColumn.Hidden = True

oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.Orient ation = 2

oExcel.ActiveWorkBook.Activesheet.PageSetUp.LeftMa rgin = oExcel.Application.InchesToPoints(0.25)
oExcel.ActiveWorkBook.Activesheet.PageSetUp.RightM argin = oExcel.Application.InchesToPoints(0.25)
oExcel.ActiveWorkBook.Activesheet.PageSetUp.TopMar gin = oExcel.Application.InchesToPoints(0.5)
oExcel.ActiveWorkBook.Activesheet.PageSetUp.Bottom Margin = oExcel.Application.InchesToPoints(0.5)

oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.Zoom = False

oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.FitToP agesWide = 1
oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.FitToP agesTall = 1

x = oExcel.ActiveWorkBook.ActiveSheet.UsedRange.Rows.C ount

if x < 20 then
h = 30
f = 10
elseif x > 20 and x < 30 then
h = 25
f = 10
else
h = 17
f = 7
end if
for x = 4 to x - 1
sRow = "A" & x
oExcel.ActiveWorkBook.ActiveSheet.Range(sRow).RowH eight = h
next
oExcel.ActiveWorkBook.ActiveSheet.Columns("A:H").F ont.Size = f


end sub


Sub ErrorProc
msgbox err.description
End Sub

Additionally on several machines the script use to work and now stops in mid script. I do not get an error message. The script simply stops executing.
Thank you in advance for your help
Jun 11 '07 #1
3 2615
r035198x
13,262 8TB
I added this code to a an ASP page to print a gridview in Microsoft Excel. This page is a weekly work schedule for our company's intranet. The code works on a majority(80%) of the workstations in our business. On those machines that stop in mid script. The excel object is opened and visible; however the script stops executing at the line:
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML <----- Script stops executing at this point


The whole code:
Sub exportbutton_onclick
Const xlCellTypeLastCell = 11
dim sHTML, oExcel, oBook, LastRowWithData, Row
Dim ExcelLastCell, LastRow
If Err.Number > 0 Then
Call ErrorProc
End If

sHTML = document.all.item("dgWeekly_Plan").outerhtml
set oExcel = CreateObject("Excel.Application")
set oBook = oExcel.Workbooks.Add
oExcel.Visible = true
oExcel.UserControl = true
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML <----- Script stops executing at this point

oBook.HTMLProject.Refreshdocument

oExcel.ActiveWorkBook.ActiveSheet.Range("A2").Enti reColumn.Hidden = True
oExcel.ActiveWorkBook.ActiveSheet.Range("H2").Enti reColumn.Hidden = True

oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.Orient ation = 2

oExcel.ActiveWorkBook.Activesheet.PageSetUp.LeftMa rgin = oExcel.Application.InchesToPoints(0.25)
oExcel.ActiveWorkBook.Activesheet.PageSetUp.RightM argin = oExcel.Application.InchesToPoints(0.25)
oExcel.ActiveWorkBook.Activesheet.PageSetUp.TopMar gin = oExcel.Application.InchesToPoints(0.5)
oExcel.ActiveWorkBook.Activesheet.PageSetUp.Bottom Margin = oExcel.Application.InchesToPoints(0.5)

oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.Zoom = False

oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.FitToP agesWide = 1
oExcel.ActiveWorkBook.ActiveSheet.PageSetUp.FitToP agesTall = 1

x = oExcel.ActiveWorkBook.ActiveSheet.UsedRange.Rows.C ount

if x < 20 then
h = 30
f = 10
elseif x > 20 and x < 30 then
h = 25
f = 10
else
h = 17
f = 7
end if
for x = 4 to x - 1
sRow = "A" & x
oExcel.ActiveWorkBook.ActiveSheet.Range(sRow).RowH eight = h
next
oExcel.ActiveWorkBook.ActiveSheet.Columns("A:H").F ont.Size = f


end sub


Sub ErrorProc
msgbox err.description
End Sub

Additionally on several machines the script use to work and now stops in mid script. I do not get an error message. The script simply stops executing.
Thank you in advance for your help
Don't ask questions in the articles section.
Moved to the forum.
Jun 16 '07 #2
kenobewan
4,871 Expert 4TB
Sorry about this but we need to move to the asp forum as I don't believe this is an IIS problem.
Jun 17 '07 #3
r035198x
13,262 8TB
Sorry about this but we need to move to the asp forum as I don't believe this is an IIS problem.
keno is right. And so I'll move it again and this time to the ASP forum.
Jun 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: hepp | last post by:
Is it possible to run a Python script in Windows without installing Python on your machine first? At my work we are using a mixed environment - some have Solaris workstations and others PC's. I...
2
by: RJ | last post by:
We currently send product releases to our customers, and often have to include scripts that need to be ran on the Oracle databases (also do it for SqlServer customers, but we use a different set of...
13
by: PamelaDV | last post by:
I have a database split for back end and front end and my back end (my data) has been corrupting like crazy lately. Today we have compacted and repaired like 4 times within an hour. The database...
6
by: Bas | last post by:
I'm using If File.Exists("c:\docs\myfile.txt") msgbox("Found") End This work fine on machine with Vb.Net installed but NOT on regular workstations ie. when deployed!! Any ideas?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.