I'm doing the following in VBA:
Open another database:
Then pick some macro from the other target database and export it to a textfile:
Now I look into the created file with notepad and it looks as expected:
Now I look into the created file with a hex editor UltraEdit - see screenshot.
How did the bad characters hex FF, FE, 00 end up in the file??
NOTE: when using SaveAsText within the CURRENT database, I'm not experiencing this problem.
Open another database:
Code:
[SIZE=2]Private Sub OpenTargetDB()[/SIZE]
[SIZE=2]Set accapp = New Access.Application[/SIZE]
[SIZE=2]accapp.OpenCurrentDatabase (TargetDBName)[/SIZE]
[SIZE=2]'accapp.Visible = True[/SIZE]
[SIZE=2]End Sub[/SIZE]
Code:
[SIZE=2]Dim i As Integer[/SIZE]
[SIZE=2]Dim obj[/SIZE]
[SIZE=2]For Each obj In accapp.CurrentProject.AllMacros[/SIZE]
[SIZE=2]If obj.Name = myMacroName Then[/SIZE]
[SIZE=2]FileName = ThisDbPath & "Macro_" & obj.Name & ".txt"[/SIZE]
[SIZE=2]FileNameo = ThisDbPath & "Macro_" & obj.Name & "_report.txt"[/SIZE]
[SIZE=2]accapp.SaveAsText acMacro, obj.Name, FileName[/SIZE]
[SIZE=2]End If[/SIZE]
[SIZE=2]Next[/SIZE]
Now I look into the created file with notepad and it looks as expected:
Code:
[SIZE=2]Version =196611[/SIZE]
[SIZE=2]ColumnsShown =0[/SIZE]
[SIZE=2]Begin[/SIZE]
[SIZE=2]Action ="SetWarnings"[/SIZE]
[SIZE=2]Argument ="0"[/SIZE]
[SIZE=2]End[/SIZE]
[SIZE=2]Begin[/SIZE]
[SIZE=2]Action ="OpenQuery"[/SIZE]
[SIZE=2]Argument ="create_01_bedraga"[/SIZE]
[SIZE=2]Argument ="0"[/SIZE]
[SIZE=2]Argument ="1"[/SIZE]
[SIZE=2]End[/SIZE]
[SIZE=2]... etc etc[/SIZE]
Now I look into the created file with a hex editor UltraEdit - see screenshot.
How did the bad characters hex FF, FE, 00 end up in the file??
NOTE: when using SaveAsText within the CURRENT database, I'm not experiencing this problem.