What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Matty needs VBScript help.

Matty needs VBScript help.
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
O.P. Matty needs VBScript help.
Ok everyone, a guy at work needed help with something so I said I will see what I can do.

Basically we work in a call center doing tech support so he gets a document with daily stats for each employee. Now what we are trying to do is pull the stats per person according to employee number. The thing is each computer by default has Excel Viewer, you cannot make changes to any excel file, just read from them. Now when you have the full Excel installed the code works fine. But when you don't you get cannot create activeX Object. Here is our code.

code:
<html>

<head>
</head>
<body>
<script language="VBScript">

    Dim ExcelApp, ExcelWB
    Dim Cells
    Dim objNet
    Dim oracle
    Dim xc

set objNet = CreateObject("WScript.NetWork")
oracle = "33075" 'objNet.username
document.write("<table border=1 id=table1 bordercolorlight=#FFFFFF bordercolordark=#FFFFFF><tr><td bordercolorlight=#4985B6 bordercolordark=#4985B6 bgcolor=#FFFFFF><p align=center><font size=1 face=Verdana>Stats for: " & oracle & "</font></td></tr><tr><td bordercolorlight=#4985B6 bordercolordark=#4985B6><table border=0 id=table2>")
   
    set ExcelApp = createobject("Excel.Application")
    ExcelApp.visible = False
    set ExcelWB = ExcelApp.Workbooks.Open("C:\Documents and Settings\Matt\Desktop\Stats\dailystats.xls")
    Set Cells = ExcelApp.Worksheets(1).Cells
    getpos
    printstats
    Set ExcelApp = Nothing

Private Function getpos()
    for i = 1 to 340
        if oracle = TRIM(Cells(i,3).value) then
            xc = i
        end if
    Next
end function

Private Function printstats()
    for i = 1 to 43
        document.write("<tr><td  width=158><font face=Verdana size=1>" & rtrim(trim( Cells(10,i))) & "</font></td><td width=58><font face=Verdana size=1>" & rtrim( trim(Cells(xc,i))) & "</font></td></tr></div>")
    Next
end function

</script>
    </tr></table></td></tr></table>
</body>
</html>

Now we tried using
code:
set ExcelApp = createobject("Excel.Sheet")

And that failed miserably. Can anyone help us out?
01-29-2005 07:50 AM
Profile E-Mail PM Find Quote Report
kao
Veteran Member
*****

Avatar
boring

Posts: 1814
Reputation: 52
37 / Male / Flag
Joined: Jul 2003
Status: Away
RE: Matty needs VBScript help.
isnt the
code:
<html>

<head>
</head>
<body>
and
code:
</tr></table></td></tr></table>
</body>
</html>
completely pointless? if its VB then why have html? :dodgy:
01-29-2005 01:40 PM
Profile PM Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: Matty needs VBScript help.
quote:
Originally posted by Kao
isnt the
code:
<html>

<head>
</head>
<body>
and
code:
</tr></table></td></tr></table>
</body>
</html>
completely pointless? if its VB then why have html? :dodgy:


It's VBScript which is embedded into the webpage, hence
code:
<script language="VBScript">

</script>

The previous sentence is false. The following sentence is true.
01-29-2005 03:39 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Matty needs VBScript help.
Some wild random first thoughts (don't have much experience with createobject and/or office viewers):

[list=1][*]I think the problem is that Excelviewer doesn't install the Excel ActiveX object component (Excel does of course), so you can't use it.
[*]What about, instead of using CreateObject, you use GetObject?
[*]
quote:
Originally posted by Matty
set ExcelApp = createobject("Excel.Sheet")
Isn't it "Excel.Worksheet"?
[*]some (related) links. Ddunno if they help anything though, but maybe they give some other ideas to start searching from:
http://support.microsoft.com/default.aspx?scid=kb;en-us;168973
http://support.microsoft.com/default.aspx?scid=kb;en-us;168972
http://whidbey.msdn.microsoft.com/library/default...celspreadsheet.asp[/list]
http://forum.jswelt.de/printthread.php?t=6300
http://officewriter.softartisans.com/officewriter-37.aspx

This post was edited on 02-12-2005 at 04:15 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
02-12-2005 03:59 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On