|
-
May 24th, 2012, 05:09 PM
#1
Thread Starter
Addicted Member
FlexGrid Color Row, Saving DAT Files, Excel Spreadsheet Help!
Dear Reader,
As you can tell from the title this Thread is a little scatterbrained and I apologize. Basically my problem is this. I have a FlexGrid with a color changing button that when you select the color and hit "Apply" it changes the Row of the FlexGrid. Now, the FlexGrid is tied directly into an Excel Spreadsheet that the user Opens by going to File>Open. So here is my problem,
In the FlexGrid, say I changed Row #1 to Red because the in the Spreadsheet that the User opened inside the FlexGrid, Row #1 was a bad column of data. Not bad like incorrect but bad as in the information was not the kind they were looking for. Therefore, the whole point of the color coding stuff is to label bad, good, problems, etc.
The code that I have for the Color Coding is as follows, and contains DAT file information:
Code:
Private Sub ApplyColor(PColor As Long)
With fgROList
.FillStyle = flexFillRepeat
.Col = .FixedCols
.ColSel = .Cols - 1
.CellBackColor = PColor
.FillStyle = flexFillSingle
End With
End Sub
Private Sub cmdApplycolor_Click()
ApplyColor commonDialogColorBox.Color
End Sub
Private Sub cmdSelectColor_Click()
With commonDialogColorBox
.Flags = cdlCCRGBInit Or cdlCCFullOpen
.ShowColor
lblColor.BackColor = .Color
End With
End Sub
Private Sub DoSomething()
With fgROList
.Rows = 10
.Cols = 5
.SelectionMode = flexSelectionByRow
.FocusRect = flexFocusNone
End With
LoadFlexFormat
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
SaveFlexFormat
End Sub
Private Sub SaveFlexFormat()
Dim fso As Object, TS As Object, i As Long
Set fso = CreateObject("Scripting.FileSystemObject")
Set TS = fso.CreateTextFile(App.Path & "\FlexColors.DAT", True)
With fgROList
.Col = .FixedCols
For i = fgROList.FixedRows To fgROList.Rows - 1
.Row = i
TS.WriteLine fgROList.CellBackColor
Next
End With
TS.Close
Set TS = Nothing
Set fso = Nothing
End Sub
Private Sub LoadFlexFormat()
Dim fso As Object, TS As Object, StrItem As String
Set fso = CreateObject("Scripting.FileSystemObject")
If Dir(App.Path & "\FlexColors.DAT") = vbNullString Then
Set fso = Nothing
Exit Sub
Else
Set TS = fso.OpenTextFile(App.Path & "\FlexColors.DAT", 1)
End If
With fgROList
Do While Not TS.AtEndOfStream
StrItem = TS.ReadLine
If TS.Line - 1 < .Rows Then
.Row = TS.Line - 1
If CLng(StrItem) <> 0 Then ApplyColor CLng(StrItem)
End If
Loop
.Row = .FixedRows
.Col = .FixedCols
.ColSel = .Cols - 1
End With
TS.Close
Set TS = Nothing
Set fso = Nothing
End Sub
This all applies to the FlexGrid called fgROList.
The problem, I think, lies with Excel. Maybe the Colored Rows need to be changed simultaneously in the Spreadsheet as well as the Rows in VB? I'm not sure. Another worthy statement might be to review the possibility that when the DAT file saves it might not Open and Apply it to the Spreadsheet that it opens. Because keep in mind every employee here opens up a different Spreadsheet.
So, if Employee #1 opened Spreadsheet X up and marked Rows #1 and #2 as Blue. I need that same Spreadsheet to have those colors applied if Employee #2 opened up Spreadsheet X the next day.
Let me know if I left out any information or if you need anymore. I would zip the whole folder but it's bigger than the requirements.
My code is at your disposal so if you have any questions, comments, or replies I would GREATLY appreciate them.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|