PDA

View Full Version : selection.font VBA error



Thom
05-30-2008, 08:52 AM
Hi all

The project I was working on was working just fine. THen I changed a couple of things which didn't work so reverted back to a different saved working version.

"Object variable or With block variable not set"
The error is at the line in red:


XLSheet.Cells.Select
With Selection.Font
.Name = "Verdana"
.FontStyle = "Norm?l"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With


All the code is pretty long so I dont want to post it all. But essentially, i press a button in Access and it opens Excel, creates a few blank sheets and then selects all the cells. That bit works, it selects all the cells. Now, like I said before (and I am not lying :bug:) the code worked before. it's basically applying any formatting and it errors.

Any thoughts?

Thanks

Thom

Oorang
05-30-2008, 09:37 AM
Hi Thom. Try:
With XLSheet.Cells.Font

Thom
06-02-2008, 08:44 AM
Hi thanks for the reply.

It actually worked fine when I tried it this morning. I don't know if there were server problems at the time of the error. Very frustrating! :banghead: