By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,395 Members | 2,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,395 IT Pros & Developers. It's quick & easy.

DoCmd.OutputTo vs. Macro Sheet

P: n/a
I've got a user who's trying to export a text file with unicode
formatting. When he exports it as straight ascii, some of the foreign
characters (mostly just accent marks and the like - no non-roman
characters that I can see) don't come through right. So he needs it in
Unicode formatting. He's using code for the DoCmd.OutputTo command.
There's a very undocumented Encoding option for that command, but no
options are specified and there's precisely squat online. So I figured
if it was a DoCmd line that I could do the same thing with a macro.
Wouldn't you know it, I could specify the unicode option in the macro
and the file would output correctly! Problem is, he's got a batch of
these things, and the filename changes - the name is taken from the
object number he's reporting on. I tried specifying in the macro sheet
that the filename is:

"c:\dmpfiles\" & [Forms]![smi_one]![cdnum] & ".txt"

but that caused an error in the macro execution. Interestingly enough,
when the halt screen came up it showed the variables it was passing to
the actual OutputTo command, and the encoding option was the number
1200. So I went back into the code and tried specifying 1200 as the
encoding option. It's weird - the macro creates a unicode file when it
passes the 1200 argument, but the vba doesn't, even though it's passing
the exact same variables. So, I thought, no big deal - I'll just edit
the macro right before it runs. Maybe I wasn't looking in the right
place, but I couldn't find any why of modifying an existing macro. My
thought is to just edit the macro before it runs and giving it the
filename it should save as. Anyone know how to use VBA to edit a macro?
Better yet, any way to get the DoCmd.OutputTo to actually output in
Unicode format?

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
Export the text file to where?

Nov 13 '05 #2

P: n/a
The command should be outputting a report to a text file on the user's
hard drive - for example, one filename would be
"c:\dmpfiles\8452178.txt" - the 8452178 is being pulled from a control
on the form.

Nov 13 '05 #3

P: n/a
"tmountjr" <tm******> wrote in

Anyone know how to use VBA to edit a macro?

Macros can be exported to visual basic (right-click on the macro,
Save AS -> module )

You should then be able to figure out what Access is doing and
incorporate that into your code.

However, I see the same issue as you report, e.g. a bug in the
DoDmd.OutputTo method, as it appears to ignore the unicode option

Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #4

P: n/a
This afternoon I tried putting in "1200" instead of 1200 - still
nothing. I'm guessing you're right - Access completely ignores that
option, no matter what. I did, however, find a way around the problem.
I created a macro sheet that exported my reports to a static filename
(txt_all.txt, for example), then created a FileSystemObject and used
the GetFile method to load up that file and rename it. The code calls
the macro as many times as necessary and dynamically renames the static
files depending on which cd number is being processed.

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.