Formatting doesn't show up on different computer

R

Rasta

Hi,

I have the below code which formats and Excel file and then opens the file.
When I run it on a different system none of the formatting shows up. What
could be causing this? Both systems are running Excel 2002.

Function FormatPageEventTracking(sFilename As String)
Dim appXL As Excel.Application
Dim wbkW As Excel.Workbook
Dim raR As Excel.Range
Dim blnExcelRunning As Boolean

blnExcelRunning = IsExcelRunning()
If blnExcelRunning Then
Set appXL = GetObject(, "Excel.Application")
Else
Set appXL = CreateObject("Excel.Application")
End If

DoCmd.Hourglass True
On Error Resume Next
Set wbkW = appXL.Workbooks.Open(sFilename)
If wbkW Is Nothing Then
MsgBox "Couldn't open " & Filespec, _
vbExclamation + vbOKOnly
Exit Function
End If
On Error GoTo 0

Set raR = wbkW.Worksheets("Event Tracking").Cells
With raR

With .Font
.Name = "MS Sans Serif"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
End With

End With

Set raR = wbkW.Worksheets("Event Tracking").Rows("1:1")
With raR
.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlMedium
.Borders(xlEdgeTop).ColorIndex = xlAutomatic
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeBottom).Weight = xlMedium
.Borders(xlEdgeBottom).ColorIndex = xlAutomatic
.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone

With .Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 11
End With
End With
For rwIndex = 1 To 100
For colindex = 1 To 13

If InStr(wbkW.Worksheets("Event Tracking").Cells(rwIndex,
colindex).Value, "Total") > 0 Then

Set raR = wbkW.Worksheets("Event Tracking").Rows(rwIndex)
With raR

.Borders(xlDiagonalDown).LineStyle = xlNone
.Borders(xlDiagonalUp).LineStyle = xlNone
.Borders(xlEdgeLeft).LineStyle = xlNone

With .Font
.Bold = True
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With

With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 1
End With

With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 1
End With

.Borders(xlEdgeRight).LineStyle = xlNone
.Borders(xlInsideVertical).LineStyle = xlNone

End With

Set raR = wbkW.Worksheets("Event Tracking").Cells(rwIndex,
colindex)
raR.Cut
Set raR = wbkW.Worksheets("Event Tracking").Cells(rwIndex,
colindex - 1)
wbkW.Worksheets("Event Tracking").Paste Destination:=raR

Set raR = wbkW.Worksheets("Event Tracking").Cells(rwIndex,
colindex + 1)
raR.Cut
Set raR = wbkW.Worksheets("Event Tracking").Cells(rwIndex,
colindex)
wbkW.Worksheets("Event Tracking").Paste Destination:=raR

Set raR = wbkW.Worksheets("Event Tracking").Cells(rwIndex,
colindex + 2)
raR.Cut
Set raR = wbkW.Worksheets("Event Tracking").Cells(rwIndex,
colindex + 1)
wbkW.Worksheets("Event Tracking").Paste Destination:=raR

Set raR = wbkW.Worksheets("Event Tracking").Rows(rwIndex)
raR.EntireRow.AutoFit
End If

Next colindex
Next rwIndex

Set raR = wbkW.Worksheets("Event Tracking").Columns("B:C")
With raR
..NumberFormat = "$#,##0.00"
End With

Set raR = wbkW.Worksheets("Event Tracking").Columns("A:L")
raR.EntireColumn.AutoFit
wbkW.Save

DoCmd.Hourglass False

appXL.Visible = True

Set appXL = Nothing

End Function
 
G

Guest

You might want to check the security settings in Excel on the other computer.
I've had issues with scripting to/and/in Excel because the users Excel
security settings were set to High.

Just a thought,
Mens Militis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top