Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, June 20, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Open an Excel Template on local drive
Chris Schone
Posts: 8
 
Open an Excel Template on local driveYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 07 9:03 AM
Hello,
I am trying to open an Excel spreadsheet from a button.
I have the path but I get an error 424 everytime I try to launch.
Here is what I have (kinda new at this) any help is appreciated.
It gives me the error on the
objExcel.Documents.Open sPath
statement I believe.


On Error Resume Next
Dim objExcel,sFilename,sSQL,sID,cn,rs,sTemp,Ilength,sPath

dim slxconn
dim slxrecst
dim i
Dim XL
Dim XLB 'Excel Workbook
Dim XLS 'Excel Sheet
Dim stracctmgr

sPath ="C:\Documents and Settings\All Users\Application Data\SalesLogix\Library\Steel\Purchasing\Blank Quote Worksheet.xls"
if lcase(right(trim(sPath),3))<>"xls" then
msgbox "The Path specified is not an Excel Spreadsheet. Please enter a valid path.",vbOKONLY +vbExclamation,"Invalid Path"
Exit Sub
end if

if sPath ="" then
msgbox "You must set a network path for you Blank Quote Template",vbOKONLY+vbExclamation,"Network Path Not Found"
'lueBlankQuotePath.Lookup
Exit Sub
end if

sID Application.BasicFunctions.CurrentAccountID

Set cn =Application.GetNewConnection
Set rs = cn.Execute(sSQL)
sFileName="Blank Quote Worksheet.xls"
XL.Visible=True

Set XLB = XL.WorkBooks
Set XLS = XLB.Sheets("Quote Worksheet")

if rs.EOF <>True then
'Open new local Excel XLS
Set objExcel = CreateObject("Excel.Application")
Err.Clear
objExcel.Documents.Open sPath
If Err.Number > 0 then
msgbox "Template Path Not Valid. Please enter a valid Network Path" & " " & sPath & " " & Err.Number, vbOKONLY+vbExclamation,"Incorrect Path"
'Close the Excel document and clear memory
objExcelL.ActiveDocument.Close
objExcel.Quit
Set objExcel=Nothing
Exit Sub
End If
'objExcel.Selection.Find.ClearFormatting
'objExcel.Selection.Find.Replacement.ClearFormating
End if
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Open an Excel Template on local driveYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 07 12:41 PM
Well, a 424 error is basically "object reference not set to an instance of an object". Looking at the code, you have a variable called "XL", yet you never set that variable to an instance of an object - thus the error.

The first time I see you use that variable is for the line:
XL.Visible=True

But before that in the code, you don't set the variable to an object, at that point it is still nothing.

Does that make sense?

-Ryan
[Reply][Quote]
Chris Schone
Posts: 8
 
Re: Open an Excel Template on local driveYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Nov 07 11:56 AM
Perfect sense.
Got it working now.
Thanks
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 6/20/2025 11:15:10 PM