Skip to main content

Posts

Clear temparary files from temp folder of internet explorer using .net code

To Clear temporary files from temp folder of internet explorer by .net code you can try below code in any event to check the effect. "using System.IO;" void clearTempfolder(DirectoryInfo MyDirPath) { foreach (FileInfo yourFile in MyDirPath.GetFiles()) { yourFile.Delete(); } foreach (DirectoryInfo youSubFolder in MyDirPath.GetDirectories()) { clearTempfolder(youSubFolder ); } } public static void Main() { clearTempfolder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache))); }

select the non empty cell and clear the content to allow another selection in Excel

select the non empty cell and clear the content to allow another selection. Sub ReferenceNonEmptyCells() Dim rngAll As Range Dim rngConstants As Range Dim rngFormulas As Range ' 1. reference complete range Set rngAll = Worksheets("Data").Range("A1:K30&qu ot;) ' or use named range... Set rngAll = Worksheets("Data").Range("MyRange&q uot;) ' Reference Constants (23=Numbers+Text+Logical+Errors) On Error Resume Next Set rngConstants = rngAll.SpecialCells(xlCellTypeConstants, 23) ' Reference Formulas Set rngFormulas = rngAll.SpecialCells(xlCellTypeFormulas, 23) '-- ' Clear (or ClearContents) Non Empty Cells If Not rngConstants Is Nothing Then rngConstants.ClearContents End If If Not rngFormulas Is Nothing Then rngFormulas.ClearContents End If End Sub

Convert xml file to excel using vb.net code

Private Function XmlToExcelfile(ByVal XMLSourcefileAs String, ByVal ExcelfileAs String)         Dim Exapp As New Excel.Application Dim fileInf As New System.IO.FileInfo(XLSFile) If fileInf.Exists Then SetAttr(XLSXFile, vbNormal) fileInf.Delete() End If Dim fxml As New System.IO.FileInfo(XMLFile) If fxml.Exists Then exapp.Workbooks.Open(XMLFile) exapp.Workbooks.Item(1).CheckCompatibility = True exapp.DisplayAlerts = False exapp.Workbooks.Item(1).SaveAs(XLSXFile,exappcel.XlFileFormat.xlWorkbookDefault) exapp.DisplayAlerts = False exapp.Workbooks.Close() SetAttr(XMLFile, vbNormal) fxml.Delete() Else MessageBox.Show("XML File does not exists") End If Dim file2 As New System.IO.FileInfo(XLSXFile) If file2.Exists Then SetAttr(XLSFile, FileAttribute.Normal) End If exapp.Quit() Exapp= Nothin

Saving .xlsx file as .xls file by macro code in excel

Sub SaveAs(Filename As String, Format As String) 'XLS Format If UCase(Format) = "XLS" Then ActiveWorkbook.SaveAs Filename:= _ Filename, FileFormat:= _ xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False Else 'default 'XLSX Format ActiveWorkbook.SaveAs Filename:= _ Filename, FileFormat:= _ xlOpenXMLWorkbook, CreateBackup:=False End If End Sub Sub Test() SaveAs "C:\tmp\Filename.xls", "xlsx" SaveAs "C:\tmp\Filename.xlsx", "xls" End Sub

Insert Values Into Table Using Stored Procedure With Identity Column

--First step is create Table empmaster with column empid,eno,ename etc create table empmaster ( empid int primary key identity, eno int, ename varchar ) -- Now create Table empdetails with column empid,sal,dept, hiredate etc create table empdetails ( empid int , sal money, dept varchar, hiredate datetime ) -- Now create Stored Procedure empvalues to insert records in tables create proc empvalues @eno int, @ename varchar(20), @sal money, @dept varchar(20), @hiredate datetime as begin insert into empmaster . INSERT INTO empdetails. end