Solved

EASY QUESTION - Easy Points!! How to Print a file from a batch command in Landscape.

Posted on 2003-11-25
15
502 Views
Last Modified: 2007-12-19
Hi,
I have a batch file that is successfully printing a Excel Spreadsheet. however, the spreadsheet is too big and alotta data doesnt come in on one sheet, that is why i wanna print it out in landscape. Is there a way, we can change settings through command line?
0
Comment
Question by:skhan2
  • 4
  • 3
  • 2
  • +4
15 Comments
 
LVL 3

Accepted Solution

by:
IGneon10 earned 25 total points
ID: 9822161
I don't think so, but you could go into the Excell print setup properties and change it there.  That should keep it in landscape for printing.
0
 
LVL 11

Expert Comment

by:Paul S
ID: 9822882
paste code here and we will see.
0
 
LVL 13

Expert Comment

by:WillHudson
ID: 9823449
You'd have to change the document itself to landscape (file--> page setup -> landscape) and save it. Then if you print it through dos, it will automatically print it landscape.
0
 

Author Comment

by:skhan2
ID: 9826744
Hi,

1. The spreadsheet itself is in portrait.

2. Here is the code:

@echo off
setlocal

if "%1"=="" goto ERROR
set RESONO=%1%

REM echo %RESONO%

if "%2"=="" goto ERRORNUMBER
set  NUMBER=%2%
REM echo %NUMBER%

set rootdirpre=report
set rootdirpost1=_%RESONO%_sk
set rootdirpost2=UPD%RESONO%\UPD%RESONO%_BATCH
set rootdirpost3=UPD%RESONO%\PRJ%RESONO%
set rootdirpost4=UPD%RESONO%
set rootdirpost5=UPD%RESONO%_INSTALL
set rootdirsrccblbase=src\cbl\base
set PRJNAME=PRJ%RESONO%

@echo off
if EXIST c:\%rootdirpre%\%NUMBER%%rootdirpost1%\%rootdirpost5% (goto :_FOUNDDOCS) else (goto :_NOTFOUNDDOCS)

echo.

exit

echo off

:_FOUNDDOCS
echo %rootdirpost5% folder has been detected
echo.
echo.
echo Printing all docs under c:\%rootdirpre%\%NUMBER%%rootdirpost1%\%rootdirpost5%
echo.
%SystemRoot%\SYSTEM32\PRINT.EXE /d:"\\bur-print-02\P10-HEAD HUNTER" c:\%rootdirpre%\%NUMBER%%rootdirpost1%\%rootdirpost5%\*.*
exit

:_NOTFOUNDDOCS
if EXIST c:\%rootdirpre%\%NUMBER%%rootdirpost1% (echo There is no %rootdirpost5% folder found!)
echo Please check your Inputs. There is no path detected c:\%rootdirpre%\%NUMBER%%rootdirpost1%
exit


:ERROR
echo  ERROR Please enter a Resolution ID
echo  Example= 123456  

:END

:ERRORNUMBER
echo  ERROR Please enter a the No. of Resolution you are working on since last Build
echo  Example= 1 or 2 or 3...

:END
0
 

Expert Comment

by:FreekHendriks
ID: 9828558
Changing to landscape, changes the lay-out ... wich can only be done by the software. (or driver)

By using headers or something you can maybe select an other papertray, but the data stays the same....
I've tried to print to a file and analyse the header of that file.... I can only see a few options, but not the papersize and lay-out.
It is stored in the print-data.

I do too think you have to change the pagelayout in Excel before you print it.
0
 
LVL 11

Expert Comment

by:Paul S
ID: 9828715
get regmon from system internals ( i think they make it) change the settings in excel and see where in the registry that info is saved then add some code to change the registry.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 38

Expert Comment

by:BillDL
ID: 9832224
Yes, Guru, it is their tool:

Regmon for Windows 9x/ME/NT/2K/XP
Copyright (C) 1996-2002 Mark Russinovich and Bryce Cogswell
Regmon v6.06
This monitoring tool lets you see all Registry activity in real-time. It works on all versions of WinNT/2K, Windows 9x/Me and Windows 64-bit.

http://www.sysinternals.com/ntw2k/source/regmon.shtml

Regmon Win9x/Me - (72 KB):
http://www.sysinternals.com/files/regmon95.zip

Regmon WinNT/2K/XP - (72 KB):
http://www.sysinternals.com/files/ntregmon.zip

Regmon XP 64-bit Edition/IA64 - (116 KB ):
http://www.sysinternals.com/files/regmon64.zip
0
 

Author Comment

by:skhan2
ID: 9852048
Thanks Bill and Guru,

OK, So I have downloaded Regmon, and I can see all Registry activity. However, I clear the screen, Change my settings in Excell and then stop capturing in Regmon. When I look at the output, there are hundreds of entries in there. How do I find out which one will I need? If anyone can help me spot which file is in the Registry that saves all the settings, then I know how to call it from my batch file.

Thanks a bunch!
0
 
LVL 38

Expert Comment

by:BillDL
ID: 9855086
Actually, I agree with IGneon10 on this one.  I was just supplying the web addresses.

Once you have set the .xls file to landscape and "fit to page", etc, it is saved within the file itself.  I suppose this could be done from the command line with a .vbs (Visual basic) or  .wsh (Windows Host Script) run from the command line through c:\windows\command\CScript.exe, but it's something I don't know enough about to start giving you a half-baked answer.

Here's the binary content of a saved file "book1.xls" after setting it to landscape, but it has no content:

***** ANSI SECTION *****

0000022B: My office "Username" is shown here
00000726: Sheet1 (I use a default of 1 sheet for each new workbook)
000008C2: DLLName16
000008CC: EPIGUE4G.
000008E2: DLLName32
000008EC: EPID2E4G.
00000902: EPSON Stylus COLOR 760
00001298: Microsoft Excel
000022C8: Sheet1
000022DF: Worksheets


***** UNICODE SECTION *****

0000031E: aArial1
0000033C: aArial1
0000035A: aArial1
00000378: aArial?
000007EE: EPSON Stylus COLOR 760
0000081E: (Copy 2)
00003400: Root Entry
00003480: Workbook
00003502: SummaryInformation  (presumably the settings are stored in here)
00003582: DocumentSummaryInformation

Ihave a feeling, although I could be wrong, that any VD or WSH script would have to apply settings to the file through the "Page Setup" resource within one of the Common Dialogue or Common Controls library files such as "COMDLG32.DLL", but I'm not a VB programmer, so I'm not sure.

The only thing I can see in RegMon on mine are the files EPIGUE4G.dll and EPID2E4G.dll.  Both are Epson Printer software files.  Here's some of the content from the first file:

***** ANSI SECTION *****

0000004E: !This program requires Microsoft Windows.
000000E9: AfCP
00000131: EPIGUE4G
0000013B:
DLLENTRYPOINT
0000014D: ?GETRESOLUTION
0000015C: ZCXPEUTAGDEVMODE
0000016E: PEUPOINT32
0000017E:
PAGEUIDLGPROC
00000192: EXPORTEDSTUB
000001A1: POSTERUIDLGPROC
000001B3: JNLUIDLGPROC
000001C2: DUMMYDLGPROC
000001D1: UTYUIDLGPROC
000001E0: PAPERUIDLGPROC      
000001F1: BASICUIDLGPROC

00000202: LAYOUTUIDLGPROC
0000021E: EPIFLN51
00000227: KERNEL
0000022E: USER
0000038D:  DDRV EPSON Color Printing System
000003B1: EPDD
000003B6: GETCMDLEVEL.
000003C3:
INITERCQDM
000003D5: CURPAPERINFO
000003E3:
GET
000003E8: JNLOPTION
000003F8: PAPERINDEXS
00000406: UTYTTGETMSGPROC
00000417:
GET
0000041C: BOKCANCEL
00000428: EPDD
0000042D: GETDRIVINFO-
0000043B: ISLONGPAPER
0000044D: ENTERDEVMODE
0000045C: EPDD
00000461: GETORGDEVMODE,
00000471: ISSAMEPROPERTY
00000486: PAPERNAMES
00000497: CURRENDMODE
000004A5: PAPTTGETMSGPROC
000004B7: DETTTGETMSGPROC
000004CD: MAXCOPYNUM
000004DE: JNLPATH
000004E7:       MERGE
000004F3:
GET
000004F8: PAPERSIZE
00000504: BATTGETMSGPROC
00000515: PAPUSRTTGETMSGPROC
0000052E: MINPRINTABLE
00000541: SIZE
00000548: SAVEPRINTPROPERTIESFILE
00000562: UIENTERDEVMODE
00000572:
EPDD
00000578: GETRANGE/
00000582:
GETAPFMODE
00000590: EPDD
00000595: SETDATA1
0000059F: EPDD
000005A4: GETDATA0
000005AE: ISMONODOCCHECK
000005C3: MAXPRINTABLE
000005D2: PRESETTTGETMSGPROC
000005E6:
GET
000005EB: TILECOUNT
000005F6:
GETRESINFO
00000603:
GET
00000608: BININDEXS
00000618: BINNAMES
000459C4: EPXLPT.
00045A2C: Ports
00045A32: PORTNAME
00045A3C: PortDriver
00045A48: ECPDevice
00045D5D: C AdC
00045E84: File not found :
00045E96: COMMCTRL.
00045EA3: PropertySheet
00045EB1: CreatePropertySheetPage
00045EC9: Epictrl4.
etc, etc.

Note mention of "COMMCTRL.dll".

Here's an extract from the resources in the file "EPID2E4G.dll":

00015674: LCMapStringA
00015684: LCMapStringW
00015694: GetStringTypeA
000156A6: GetStringTypeW
000156B8: FlushFileBuffers
000156CC: CloseHandle
000156DA: SetStdHandle
000156EA: SetFilePointer
000156FC: GetLocaleInfoA
0001570E: GetLocaleInfoW
0001595C: Epid2e4g.
00015969: CopyPrintProperties
0001597D: CreatePrintProperties
00015993: CreateStruct
000159A0: DestroyStruct
000159AE: DoAutoRotate
000159BB: EPDD
000159C0: GetCmdLevel
000159CC: EPDD
000159D1: GetData
000159D9: EPDD
000159DE: GetDrivInfo
000159EA: EPDD
000159EF: GetOrgDevMode
000159FD: EPDD
00015A02: GetRange
00015A0B: EPDD
00015A10: SetData
00015A18: GetStruct
00015A26: DevModeProperty
00015A3A: PaperString
00015A4A: ReplayOption
00015A57: IsSameProperty
00015A66: ReleasePrintProperties
00015A81: ReplayOption
00015C30: EPCNF2Data
00015C3C: EPISPL10.

As you will notice, it calls even more .dll files, so ti gets quite complicated.

I believe this is really a question for the VB programming section.
0
 
LVL 11

Expert Comment

by:Paul S
ID: 9855602
i think i figured it out......


i have windows xp pro. if you do also, this should work but only on the pc that you perform these steps on. Not on any pc.

go here in registry:
HKEY_CURRENT_USER\Printers\DevModePerUser\(your printer name here)
 the (your printer name here) part should be a REG_Binary click on this key while in portrait and export key. change settings through control panel to landscape. Export same key again. then each time you need setting changed export the reg file you need. see if that works.
0
 
LVL 11

Expert Comment

by:Paul S
ID: 9855606
oops

*then each time you need settings changed import the reg file you need.
0
 
LVL 38

Expert Comment

by:BillDL
ID: 9856653
In my case with Windows 98SE, the same setting appears to be:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers\EPSON Stylus COLOR 760

Binary Value "Default DevMode" = indecipherable binary string that could well change to reflect the landscape setting.
0
 
LVL 6

Expert Comment

by:SlyDog
ID: 9883393
How about sending an escape code to the printer to set it for landscape mode just prior to printing you doc?

Try this link for info:

http://msdn.microsoft.com/archive/en-us/dnarvbtips/html/msdn_msdn116.asp

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now