View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rinze Smit Rinze Smit is offline
external usenet poster
 
Posts: 7
Default running macro step by step different from normal run??

Hello everyone,

I have created this macro which opens all textfiles (one by one) in a
directory, and makes changes to the worksheet (mostly lay-out).
When testing the macro step by step (using F8) or using the 'play-button'
from VB-editor, the code (see below) converts the document in the correct
way. The original code was created using the macrorecorder.
However when I execute the macro, using a toolbarbutton, the data is NOT
imported in the right way.

Can anybody shine some light on this matter. What am I doing wrong.
We're working with Office97 on a citrix platform.

Many Thanks
Do While myFile < ""

'Open document
Set myBook = Workbooks.Open(pathToUse & myFile)
Workbooks.OpenText Filename:=pathToUse & myFile, Origin:=xlMSDOS _
, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),
Array( _
6, 1), Array(37, 1), Array(47, 1))


'Document Omzetten
Omzetten


'Nieuwe naam geven (XLS)
Length = Len(myFile)
NwLength = Length - 4
NwFile = Left(myFile, NwLength)


'Print en Sluit het gewijzigde document na de wijzigingen
ActiveWorkbook.PrintOut Copies:=2
ActiveWorkbook.SaveAs Filename:=(PathToSave & NwFile & ".xls"),
FileFormat:=xlWorkbookNormal
ActiveWorkbook.Close


'Volgende document in de map
myFile = Dir$()
Loop

Exit Sub

Errorhandler:
MsgBox ("er is een fout opgetreden, het programma kan niet worden
voortgezet. Bel 212 of ga naar huis!")

End Sub