Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi All, I may be having a dumb day here, but.... I am getting the following error: "Cannot set HorizontalAlignment Property of the Range Class" from this code: Sub Test() With Range("G4") .Formula = "GP%" .HorizontalAlignment = xlHAlignCenter .Font.Bold = True End With End Sub It makes no difference whether I use 'xlHAlignCenter' or -4108 (the intrinsic value). G4 is not protected. Any help is much appreciated. Thanks, Alan. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
But is the worksheet protected?
Alan wrote: Hi All, I may be having a dumb day here, but.... I am getting the following error: "Cannot set HorizontalAlignment Property of the Range Class" from this code: Sub Test() With Range("G4") .Formula = "GP%" .HorizontalAlignment = xlHAlignCenter .Font.Bold = True End With End Sub It makes no difference whether I use 'xlHAlignCenter' or -4108 (the intrinsic value). G4 is not protected. Any help is much appreciated. Thanks, Alan. -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Dave Peterson" wrote in message
... But is the worksheet protected? Hi Dave, Thank you for replying. No - the worksheet is definately not protected either. In addition, the other commands (up to the point where it bombs out) work fine: For example: Sub Test() With Range("G4") .Formula = "GP%" .Font.Bold = True .HorizontalAlignment = xlHAlignCenter End With End Sub G4 is set to "GP%" okay, and the bold is set, but it then fails. Not sure if it is relavent, but the workbook is created programmatically, in a separate instance of excel from the originating workbook. Interestingly, the code works fine on another PC (both Excel 2000). Perhaps I should do a detect and repair on office on my machine? Thanks, Alan. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
Sub Test() With Range("G4") .Formula = "GP%" .Font.Bold = True msgbox xlHAlignCenter .HorizontalAlignment = xlHAlignCenter End With End Sub Does it show -4108 ? -- Regards, Tom Ogilvy "Alan" wrote in message ... "Dave Peterson" wrote in message ... But is the worksheet protected? Hi Dave, Thank you for replying. No - the worksheet is definately not protected either. In addition, the other commands (up to the point where it bombs out) work fine: For example: Sub Test() With Range("G4") .Formula = "GP%" .Font.Bold = True .HorizontalAlignment = xlHAlignCenter End With End Sub G4 is set to "GP%" okay, and the bold is set, but it then fails. Not sure if it is relavent, but the workbook is created programmatically, in a separate instance of excel from the originating workbook. Interestingly, the code works fine on another PC (both Excel 2000). Perhaps I should do a detect and repair on office on my machine? Thanks, Alan. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Tom Ogilvy" wrote in message
... Try Sub Test() With Range("G4") .Formula = "GP%" .Font.Bold = True msgbox xlHAlignCenter .HorizontalAlignment = xlHAlignCenter End With End Sub Does it show -4108 ? Hi Tom, Yep - it shows negative 4108. I already tried using that intrinsic value just in case, but it doesn't work either way. It *does* work on another machine with same install of Excel 2000 (SP3) so I am thinking I should do a Detect & Repair on this machine. If I do that, will I lose my toolbars, add-ins, personal.xls settings? I have backups of them all, but it is just a time factor of whether to do it now, or leave it till Xmas when I will be under less pressure. Thanks for your help, Alan. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't think a detect and repair will hurt any of your settings--but it can't
hurt making a backup. But before you do... Can you center this cell manually? And I've never seen this type of error with a missing reference, but it shouldn't take too long to check. Inside the VBE with your project selected. tools|References scroll down that list and look for MISSING If you see one, uncheck it and see if that helps. When bad things happen that seem to make no sense, sometimes (not always) running Rob Bovey's code cleaner can magically fix things: Rob Bovey's codecleaner can be found he http://www.appspro.com/ But if the same workbook opened on another pc works, I wouldn't get my hopes up. Alan wrote: "Tom Ogilvy" wrote in message ... Try Sub Test() With Range("G4") .Formula = "GP%" .Font.Bold = True msgbox xlHAlignCenter .HorizontalAlignment = xlHAlignCenter End With End Sub Does it show -4108 ? Hi Tom, Yep - it shows negative 4108. I already tried using that intrinsic value just in case, but it doesn't work either way. It *does* work on another machine with same install of Excel 2000 (SP3) so I am thinking I should do a Detect & Repair on this machine. If I do that, will I lose my toolbars, add-ins, personal.xls settings? I have backups of them all, but it is just a time factor of whether to do it now, or leave it till Xmas when I will be under less pressure. Thanks for your help, Alan. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to set the FormulaArrary property of the range class | Excel Worksheet Functions | |||
unable to set the formula array property of the range class | Excel Worksheet Functions | |||
Unable to set the NumberFormat Property of the Range Class - ERROR | Excel Programming | |||
Unable to set the Locked property of the range class | Excel Programming | |||
Unable to set the Locked Property of the Range Class | Excel Programming |