6/21/2025 2:33:10 AM
|
|
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!
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.
|
|
|
|
Open an Excel Template on local drive
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 |
|
|
|
Re: Open an Excel Template on local drive
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 |
|
|
| |
|
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!
|
|
|
|
|
|
|
|