I want to format a column so that all the cells in that column are percentage. Instead of doing this manually (highlight a column, right=click and select Format Cells..., and then change the Category to Percentage) I want to do it programmatically. Here is an example of how I did some formatting” 'WORD WRAP oWorkSheet.Cells.WrapText = True 'BOLD COLUMN HEADERS oWorkSheet.Range("A1", "CC1").Font.Bold() = True 'COLUMN WIDTH oWorkSheet.Columns(1).columnWidth() = 16.5 Thanks
Martin captivasystems
Posts
-
Formating a column in Excel programmatically -
Creating a new access database ERRORThank you
-
Creating a new access database ERRORThis worked: Try C:\Temp\NewDb.Mdb Why is it that it can not be created in C:\ ? Something else: how can I check if the access database exists and how can I deleted? Thanks Rob, Martin
-
Creating a new access database ERRORI’m trying to create a new access database and I get an error message that doesn’t make sense. This is the code: Dim cat As New ADOX.Catalog cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\NewDB.mdb") This is the error message: The Microsoft Jet database engine cannot open the file 'c:\newdata.mdb'. It is already opened exclusively by another user, or you need permission to view its data.; operation not complete Doesn’t make sense because: how can it be opened by another user if it doesn’t exists. Why would I need permission to view its data if I am only creating it. Any ideas about this issue? Thanks, Maritn
-
Dynamically creating DTS packageHow can I create a DTS package dynamically? I want to transfer data from tables in sql server to an access database. The access database already exists but not the tables. The tables in the access database need to be created on the fly because I don’t know what tables will be transferred. Thanks, Martin
-
Migrating SQL Server to access database using DTSHow can I use DTS to migrate some tables and views from SQL server to a new access database? I want to be able to do this programmatically, so that the windows application user can create an access database from an existing SQL server. Thanks, Martin
-
Open a NEW IE browser.How can I open a new IE browser without overwriting one that is already open? Thanks, Martin
-
ToolTip over the labelI am trying to simulate a tool tip just like the one on windows explorer. System.Windows.Forms.ToolTip shows the tool tip based on where the cursor is. I want the tool tip over the label regardless of the position of the cursor. Thanks for you help. Martin
-
Read a file from the webHow can I read a file from a web site. Let's say that the file is at http://www.thecodeproject.com/file.txt. Thanks, Martin
-
Calculating the latidude and longitude of an areaI did stop and checked the high and low Latitude/Longitude and all 4 look fine, but I get the same result with a radius of 1 mile and a radius of 12 miles. I think the DB I'm using is wrong. Do you know where I can find another zip code DB? Thanks again, Martin
-
Calculating the latidude and longitude of an areaDo you know where I can get another DB just like the one I'm using?
-
Calculating the latidude and longitude of an areaThank you for your reply. I tried your suggestion and I got the same result. I think that my zip code database is incorrect. Here is where I got the DB from : http://www.cfdynamics.com/zipbase/ If I try zip = 33182 and miles = 1 I get 71 zip codes. And if I try zip = 33182 and miles = 12 I also get 71 zip codes. This is how I get the zip codes: Private Sub getZip(ByVal LowLatitude As String, ByVal LowLongitude As String, ByVal HighLatitude As String, ByVal HighLongitude As String) If (LowLongitude.Substring(3, 1) = ".") Then LowLongitude = "-0" + LowLongitude.Substring(1, LowLongitude.Length - 1) If (HighLongitude.Substring(3, 1) = ".") Then HighLongitude = "-0" + HighLongitude.Substring(1, HighLongitude.Length - 1) Dim sql = "Select ZIP FROM ZIP_CODES WHERE latitude > '+" + LowLatitude + "' and latitude < '+" + HighLatitude + "' and longitude < '" + LowLongitude + "' and longitude > '" + HighLongitude + "';" Dim strConn As String Dim strSQL As String Dim Conn As OleDbConnection Dim objDA As OleDbDataAdapter Dim objDS As New DataSet() strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\PROJECT\zipbase.mdb" Conn = New OleDbConnection(strConn) Try Conn.Open() objDA = New OleDbDataAdapter(sql, Conn) objDA.Fill(objDS, "ZIP_CODES") Catch ex As Exception MsgBox(ex.Message) End Try Conn.Close() ComboBox1.DisplayMember = "ZIP" ComboBox1.ValueMember = "ZIP" ComboBox1.DataSource = objDS.Tables("ZIP_CODES") MsgBox(ComboBox1.Items.Count.ToString) ‘display the # of zip found End Sub THANKS AGAIN, MARTIN
-
Calculating the latidude and longitude of an areaI’m trying to get the lowlatitude, highlatidude and lowlongitude, highlongitude of an area given the zip code and the radius in miles. This is what I’ve done but I think it is incorrect. Anyone has a better calculation? Thanks, Martin Sub SetRadius(ByVal iRadius, ByVal iZip) Dim rs, SQL, iStartlat, iStartlong, LatRange, LongRange SQL = "SELECT LATITUDE, LONGITUDE FROM ZIP_CODES WHERE ZIP = '" & iZip & "'" Dim strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\PROJECT\zipbase.mdb" Dim Conn = New OleDbConnection(strConn) Conn.open() Dim cmdSelect As New OleDbCommand(SQL, Conn) Dim dr As OleDbDataReader dr = cmdSelect.ExecuteReader() While dr.Read() iStartlat = dr(0) iStartlong = dr(1) End While Conn.Close() LatRange = iRadius / ((6076 / 5280) * 60) LongRange = iRadius / (((Cos(CDbl(iStartlat * 3.141592653589 / 180)) * 6076) / 5280) * 60) LowLatitude = iStartlat - LatRange HighLatitude = iStartlat + LatRange LowLongitude = iStartlong - LongRange HighLongitude = iStartlong + LongRange end sub
-
Getting the ValueMember of a CheckedListBox given the DisplayMemberHow can I get the ValueMember of a CheckedListBox object if I know the DisplayMember? this is how I load the CheckedListBox : ComboBox1.DisplayMember = "FirstNames" ComboBox1.ValueMember = "id" ComboBox1.DataSource = objDS.Tables("table2") now I need to get the valueMember of a displayMember(ex displayMember = "John"). Thanks, Martin
-
Editing Word documentsAre ther any examples on how to edit word documents? Thanks, Martin
-
Deleting a row in a datatableHow about if I want to remove ALL rows that dont' meet that criteria Table1.Select(" Name = 'Adam' ") Dim rows() as DataRow rows = Table1.Select(" Name = 'Adam' ") If rows.Length > 0 Then Table1.Rows.Remove(rows(0)) End if Thanks, Martin
-
Deleting a row in a datatableThis is what I needed. Thanks so much, Martin
-
Deleting a row in a datatableI wasn't able to replicate your example, I never worked with the binding manager. Below is what I did. Is there a more efficint way? Dim row As DataRow Dim i As Int16 = 0 Dim ar As ArrayList = New ArrayList() For Each row In Table1.Rows If (row("Name") = "Adam") Then ar.Add(i) 'add the index of the row to be deleted End If i = i + 1 Next Dim index As Int16 For index = 0 To ar.Count - 1 Table1.Rows.RemoveAt(ar.Item(index)) Next datagrid1.SetDataBinding(Table1, Nothing) datagrid1.RetrieveStructure()
-
Deleting a row in a datatableHow can I delete a row from a datatable based on a condition. Here is what I'm trying to do: Dim row As DataRow For Each row In Table1.Rows If (row("Name") = "Adam") Then Table1.Rows.Remove(row) End If 'MsgBox(row("Name")) Next Thanks, Martin
-
Im trying to return a datatable when using OleDbCommandThanks for all your help. I ended up doing this: Public Shared Function LoadSearchResults(ByVal whereClause As String) As DataTable Dim table As DataTable = New DataTable() table.Columns.Add(New DataColumn("SSN")) table.Columns.Add(New DataColumn("REFERRED")) table.Columns.Add(New DataColumn("COMMENTS")) table.Columns.Add(New DataColumn("ADDITIONAL1")) table.Columns.Add(New DataColumn("ADDITIONAL2")) table.Columns.Add(New DataColumn("ADDITIONAL3")) Dim dr As OleDbDataReader Dim da As OleDbDataAdapter = New OleDbDataAdapter() Dim Cmd As New OleDbCommand() Try Cmd.Connection = dbConnection Cmd.CommandType = CommandType.StoredProcedure Cmd.CommandText = "qrySearchResult" Cmd.Parameters.Add(Cmd.CreateParameter()) Cmd.Parameters(0).Value = whereClause dbConnection.Open() dr = Cmd.ExecuteReader() Dim i As Int16 While dr.Read Dim ar As ArrayList = New ArrayList() For i = 0 To dr.FieldCount - 1 ar.Add(dr(i)) Next Dim row As DataRow = table.NewRow() row.ItemArray = ar.ToArray table.Rows.Add(row) End While dbConnection.Close() Return table End Function and It works fine except that MS Access ignores the where clause and returns all records. Do y:)ou know what I should do so that the query returs according to the where clause. below it the access query. SELECT SSN, REFERRED, COMMENTS, Additional1, Additional2, Additional3 FROM MAIN WHERE @WhereCluase;