Shoutbox

Matty needs VBScript help. - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Matty needs VBScript help. (/showthread.php?tid=37637)

Matty needs VBScript help. by matty on 01-29-2005 at 07:50 AM

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?
RE: Matty needs VBScript help. by kao on 01-29-2005 at 01:40 PM

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:
RE: Matty needs VBScript help. by segosa on 01-29-2005 at 03:39 PM

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>


RE: Matty needs VBScript help. by CookieRevised on 02-12-2005 at 03:59 PM

Some wild random first thoughts (don't have much experience with createobject and/or office viewers):

  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.
  2. What about, instead of using CreateObject, you use GetObject?
  3. quote:
    Originally posted by Matty
    set ExcelApp = createobject("Excel.Sheet")
    Isn't it "Excel.Worksheet"?
  4. 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