 |
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

November 4th, 2003, 09:45 AM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Opening MS-Word
hi,
This is a simple asp page, which tries to open a document by initialising the word object on the client side. For testing purpose we are using a static path.
The problem is word object is not getting initialised and we are getting an error message 'Activex Component cannot create object', this is at the line where we are trying to open the word file.
The following is our code:
'------------code start from here-----------------------
<html>
<body>
<form>
<BUTTON title="Print" ID=PrintWordFiles LANGUAGE=vbscript onclick="PrintFiles()">Print</BUTTON>
</form>
<script language="vbscript">
Function PrintFiles()
On Error Resume Next
Set wordDoc = CreateObject("Word.Application")
'If (Err.number = 429) Then 'Can't Create Object error occured..'
' msgbox err.description'
' Err.Clear
'Call ShowActiveXErr()
' Exit function
'End If
On Error GoTo err_trap
wordDoc.Visible = True
wordDoc.Documents.Open("D:\Company.doc") ' error place
worddoc.windowstate=wdWindowStateMaximize
Set wordDoc = Nothing
exit function
err_trap:
msgbox err.description & "-" & err.number
End Function
</script>
</body>
</html>
'------ end of code --------
can anybody please let me know what could be the problem and how it's to be solved.
Any alternative is also welcomed.
Thanks in advance
M.L.Srinivas
|

November 4th, 2003, 10:41 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
This code worked fine for me when I take out the On Error GoTo err_trap (you can't use this in VBS, its On Error Resume Next or nothing!).
Obvious question first, does the client have Word installed? Look in the registry at the key HKEY_CLASSES_ROOT\Word.Application\CLSID. Take the GUID from there and look up the entries under HKEY_CLASSES_ROOT\CLSID\{the GUID from above}\LocalServer32. Check that Word is actually installed to whatever path is shown there.
Also, check the Event Viewer for clues.
hth
Phil
|

November 5th, 2003, 12:27 AM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Phil,
thanks for the reply. Earlier I tried without 'on error goto..' and later i added.
Now, as you suggested I checked the registry for the path of installation of MS-Word and everything is fine.
if I remove the comments at 'err.number=429' it's displaying the error 'ActivexComponent cannot create object' and if that is commented there's no error but it's opening the document in word.
But when I checked in Task Manager I could find winword.exe. It means the object is initialised but nothing is happening after that.
Can you let me know how it behaved at your end. I did not find anything related in event viewer as well.
Thanks,
M.L.Srinivas
|

November 5th, 2003, 03:16 AM
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello The Mentioned code for opening MS Word File on client side doesn't work for although I placed a file "Company.Doc" in the E drive and changed path in the code from D to E. When I click the Print Button nothing happend at all. No Error and No word File Opend or printed.
Please guide me in this regard
Zaeem Sherazi
|

November 6th, 2003, 03:02 AM
|
Registered User
|
|
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
My problem is solved. Phil, as you said there's nothing wrong with the code, it's with the custom settings of the browser.
Any way thanks for your time.
Zaeem Sherazi, here's is the list of things to be done to solve your problem:
1. In IE goto tools>>internet options>>security>>select intranet>>custom level.
2. Then enable/prompt the 'Initialize and Script activex controls not marked as safe'.
And it will work.
M.L.Srinivas
|

November 6th, 2003, 04:49 AM
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello friend I am using the code as under but when I click the Print Button nothing happend no error and no printing. Please guide me in this regard.
I have placed the file company.doc in the E Drive,and set the security->custome level . the code is as under
----------------------------------------------------
<html>
<body>
<form>
<BUTTON title="Print" ID=PrintWordFiles LANGUAGE=vbscript onclick="PrintFiles()">Print</BUTTON>
</form>
<script language="vbscript">
Function PrintFiles()
On Error Resume Next
Set wordDoc = CreateObject("Word.Application")
'If (Err.number = 429) Then 'Can't Create Object error occured..'
' msgbox err.description'
' Err.Clear
'Call ShowActiveXErr()
' Exit function
'End If
'On Error GoTo err_trap
wordDoc.Visible = True
wordDoc.Documents.Open("E:\Company.doc") ' error place
worddoc.windowstate=wdWindowStateMaximize
Set wordDoc = Nothing
exit function
'err_trap:
'msgbox err.description & "-" & err.number
End Function
</script>
</body>
</html>
Zaeem Sherazi
|

November 6th, 2003, 08:46 AM
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 336
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Zaeem
i suggest to remove 'On Error Resume Next' line
to see any error
Ahmed Ali
Software Developer
|
|
 |