function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kutts18kutts18 

vbscript in VF page

I have a vbscript code inside my VF page,

which reads an excel file and displays the content

in a textarea.

 

Its not working at all. ie if you click the Read button

nothing happens.

 

Does VF pages support vbscript code?

 

Here is my code

 

<apex:page showHeader="false">
<apex:messages />

<script type="text/vbscript">

Sub readBtn_OnClick

Dim fileUrl
Dim rowIndex
Dim colIndex
Dim oldContent
Dim newContent
Dim cellContent

fileUrl = document.form.userFile.value
Set objExcel = CreateObject("Excel.Application")
MsgBox "Excel Obj Created"
Set objWorkbook = objExcel.Workbooks.Open(fileUrl)
MsgBox "Excel Workbook Created"

rowIndex = 1
colIndex = 1
Do Until objExcel.Cells(rowIndex ,colIndex).Value = ""
oldContent = document.form.excelContent.value
newContent = oldContent & objExcel.Cells(rowIndex , colIndex).Value & vbCr & vbLf
document.form.excelContent.value = newContent
rowIndex = rowIndex + 1
Loop
objExcel.Workbooks(1).Close
objExcel.Quit
End Sub

</script>

<form name="form">
<input type="file" name="userFile"/>
<input type="button" value="Read" name="readBtn"/>
<p><textarea rows="10" cols="44" name="excelContent"></textarea></p>
</form>

</apex:page>

 

 

Best Answer chosen by Admin (Salesforce Developers) 
kutts18kutts18

I tested this in Mozilla Firefox

 

Mozilla Firefox DO NOT SUPPORT ACTIVEX

 

so i tested in IE,its working fine when

giving appropriate security permissions.

 

http://support.mozilla.com/en-US/kb/ActiveX

All Answers

kutts18kutts18

I tested this in Mozilla Firefox

 

Mozilla Firefox DO NOT SUPPORT ACTIVEX

 

so i tested in IE,its working fine when

giving appropriate security permissions.

 

http://support.mozilla.com/en-US/kb/ActiveX

This was selected as the best answer
GiangdtGiangdt
Hi 
 
I tried to test your VF page with IE. But i get this error "ActiveX component can't create object: 'Excel.Application'". 
 
I already allowed my IE initiate and run unsigned activex as follow.
 
'Download unsigned ActiveX controls'
- Set to 'Prompt'

Initialize and script ActiveX controls not marked as safe
- Set to 'Prompt'
 
Any ideas, please?
 
Thanks
Giang.