Macro inestable

18/07/2007 - 18:59 por Pepito | Informe spam
Tengo una macro la cual ocasionalmente y sin motivo aparente empieza a
funcionar mal la he revisado no encuentro el error. La unica solucion
que me funciona es que reinicio la computadora y trabaja a la
perfeccion.




Sub Import_invent()
'
'Programa grabada el 13/02/2004
Application.ScreenUpdating = False

ChDir "C:\"
Workbooks.OpenText Filename:="C:\INVENT.TXT", Origin:=xlWindows,
StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1),
Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7,
1), Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1),
Array(14, 1), Array(15, 1), Array( _
16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20,
1), Array(21, 1), Array(22, 1), _
Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1),
Array(27, 1), Array(28, 1), Array( _
29, 1), Array(30, 1)) 'TrailingMinusNumbers:=True

Columns("A:A").EntireColumn.AutoFit <-Aqui es donde
falla el programa
Columns("B:B").EntireColumn.AutoFit
Range("A1").Select
Columns("C:C").EntireColumn.AutoFit
Range("E1").Select
ActiveCell.FormulaR1C1 = " "
Range("G1").Select
ActiveCell.FormulaR1C1 = " "
Range("I1").Select
ActiveCell.FormulaR1C1 = " "
Range("K1").Select
ActiveCell.FormulaR1C1 = " "
Range("M1").Select
ActiveCell.FormulaR1C1 = " "
Range("O1").Select
ActiveCell.FormulaR1C1 = " "
Range("Q1").Select
ActiveCell.FormulaR1C1 = " "
Range("S1").Select
ActiveCell.FormulaR1C1 = " "
Range("U1").Select
ActiveCell.FormulaR1C1 = " "
Range("W1").Select
ActiveCell.FormulaR1C1 = " "
Range("Y1").Select
ActiveCell.FormulaR1C1 = " "
Range("AA1").Select
ActiveCell.FormulaR1C1 = " "
Range("AC1").Select
ActiveCell.FormulaR1C1 = " "
Columns("D:AC").Select
Range("AC1").Activate
ActiveWindow.ScrollColumn = 21
Columns("D:AC").EntireColumn.AutoFit
Selection.ColumnWidth = 4
Selection.ColumnWidth = 4
ActiveWindow.DisplayZeros = False
Range("A1").Select
Range("B1:b1500").Select
Borrar_blancos
Macro21 ' Pasa a Otra rutina


End Sub

Alguien el foro tiene alguna idea como solventarlo..
 

Leer las respuestas

#1 Héctor Miguel
19/07/2007 - 07:13 | Informe spam
hola, jose !

... una macro... ocasionalmente y sin motivo aparente empieza a funcionar mal la he revisado no encuentro el error.
La unica solucion que me funciona es que reinicio la computadora y trabaja a la perfeccion.
Sub Import_invent()
'Programa grabada el 13/02/2004
Application.ScreenUpdating = False
ChDir "C:\" Workbooks.OpenText Filename:="C:\INVENT.TXT", Origin:=xlWindows, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15, 1), Array( _
16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array(20, 1), Array(21, 1), Array(22, 1), _
Array(23, 1), Array(24, 1), Array(25, 1), Array(26, 1), Array(27, 1), Array(28, 1), Array( _
29, 1), Array(30, 1)) 'TrailingMinusNumbers:=True
Columns("A:A").EntireColumn.AutoFit <-Aqui es donde falla el programa [...]



[como dices]... *aparentemente* no existe causa de error -?-
- a menos que el screenupdating=false te impida *ver* si [efectivamente] existe una hoja de calculo activa -?-
ya que al parecer corres otras rutinas que hacen... ???
- o que 'ocasionalmente' pierdas alguna referencia a las librerias basicas en el proyecto de macros [o en otra pc] -?-

comentas [si detectas] algun detalle mas... 'significativo' ?
saludos,
hector.

Preguntas similares