From: vqthomf on 13 Oct 2009 09:16 Hi I have created a text file in vba and I need to print the file without the user opening it first, I have tried using excel import and print this works but cuts some of the text off. I was wondering if it can be printed by send the text file to the printer??. Any help would be much appreciated. Charles
From: mayayana on 13 Oct 2009 09:33 There might be a better option than this, but you could try it: IE has an ExecWB method that basically provides access to common menu items. And IE will load a text file as plain text. (You could also, conceivably, use the DOM once the file is loaded to change the font, etc.) If you load the file into an IE instance using IE.Navigate then you should be able to print it using: IE.ExecWB 6, 2 ' -- (print, don't prompt user) > Hi I have created a text file in vba and I need to print the file without the > user opening it first, I have tried using excel import and print this works > but cuts some of the text off. I was wondering if it can be printed by send > the text file to the printer??. > Any help would be much appreciated. > Charles
From: Tom Lavedas on 13 Oct 2009 10:41 On Oct 13, 9:33 am, "mayayana" <mayaXXy...(a)rcXXn.com> wrote: > There might be a better option than this, but you > could try it: > IE has an ExecWB method that basically provides access > to common menu items. And IE will load a text file as plain > text. (You could also, conceivably, use the DOM once the > file is loaded to change the font, etc.) > If you load the file into an IE instance using IE.Navigate then > you should be able to print it using: > > IE.ExecWB 6, 2 ' -- (print, don't prompt user) > > > > > Hi I have created a text file in vba and I need to print the file without > the > > user opening it first, I have tried using excel import and print this > works > > but cuts some of the text off. I was wondering if it can be printed by > send > > the text file to the printer??. > > Any help would be much appreciated. > > Charles I think using Notepad is easier and quicker for text files, as in (assuming VBA in Excel) ... filespec = "d:\someplace\somefile.txt" shell "notepad /p " & filespec, vbHide Of course this goes to the printer connected as the default. _____________________ Tom Lavedas
From: mayayana on 13 Oct 2009 12:55 I think using Notepad is easier and quicker for text files, as in (assuming VBA in Excel) ... I didn't know about that. I suppose that a lot of programs must have a /p option. I think I'd still be inclined to use IE though *if it works properly*. That way the font style(s) can be affected easily, so that one doesn't risk being stuck with Times New Roman. It could even be printed with colors and font size options. Also, in my experience Notepad prints the file name at the top, which may not always be wanted.
From: Tom Lavedas on 13 Oct 2009 13:20 On Oct 13, 12:55 pm, "mayayana" <mayaXXy...(a)rcXXn.com> wrote: > I think using Notepad is easier and quicker for text files, as in > (assuming VBA in Excel) ... > > I didn't know about that. I suppose that a > lot of programs must have a /p option. > > I think I'd still be inclined to use IE though *if > it works properly*. That way the font style(s) > can be affected easily, so that one doesn't > risk being stuck with Times New Roman. It > could even be printed with colors and font size > options. > Also, in my experience Notepad prints the > file name at the top, which may not always > be wanted. If it's a flat file, it has no font information, so it will print with the default font in eaither application, IE or Notepad. Also, are you sure that IE7 & 8 still supports ExecWB. I don't know, but the way MS has been clamping down on the (misused) functionality over recent releases, I wonder. Notepad does indeed put in headers and footers by default, as does IE, BTW. But these can be removed. Also, a font other than the default can be selected, though not under script control, as with the IE implementation. All in all, I guess the IE implementation edges out notepad on points - but it is a pretty big guerrilla to use on a little fly. _____________________ Tom Lavedas
|
Next
|
Last
Pages: 1 2 Prev: Wrong encoding while using WinHttpRequest object ? Next: 85 Opinion Dsiconsolas.com |