How to print a graph/document using Metafile ?

Hi,

I have an MFC code written for printing a graph/document from my application 
to the printer directly. It is identifying the printer, and the document gets 
initialised in the printer spool, but it is not printing.  When i check the 
data size of the spool document it shows 0 bytes!.  As the same time, if i 
try to paste manually the data on Paint, I am getting the required output in 
paint.  ( ie. data is available on the Clipboard but not getting printed)

Can anybody help me in resolving this at the earliest.

Thanks in advance.
/////////////////////////////////////////////////////////////////////////////
void CGraphDisplayWnd::PrintGraph( void )
	{
	AssertValid();

	GLOBALHANDLE	hGMem	= NULL;
	LPMETAFILEPICT	lpmfp	= NULL;
	HMETAFILE	hMetaFile	= NULL;
	BOOL		bBlackWhite= TRUE;
	int		nMapMode	= 0;
	int		nyExt	= 0;
	int		nxExt	= 0;
	double		dAspect	= 0.0;
	CDC		DC;
	PRINTDLG		PrintDlg;
	CWQSApp* pApp = GetWQSAppPtr();

	if( !pApp->GetPrinterDeviceDefaults( &PrintDlg ) )
		{
		TRACE( "Could not get printer defaults!\n" );
		return;
		}

	if( !pApp->CreatePrinterDC( DC ) )
		{
		TRACE( "Could not open the printer!\n" );
		return;
		}

	if( PrintDlg.hDevMode != NULL )
		{
		LPDEVMODE DevMode = (LPDEVMODE)GlobalLock( PrintDlg.hDevMode );
		if( DevMode != NULL )
			{
			ASSERT( DevMode != NULL );

			if( DevMode->dmColor != DMCOLOR_MONOCHROME )
				bBlackWhite = FALSE;
			}
		GlobalUnlock( PrintDlg.hDevMode );
		}

	int nSize = 35;
	
	//	Copy Graph to Clipboard.
	GSUseView( m_nGraphNum, 0 );
	GSWinPaint( WPMETAFILE );
	GSWinPaint( WPMANUAL );
	m_nBKColor = LIGHT+WHITE;
	if( bBlackWhite )
		{
		m_Graph.SetSymbolSize( nSize );
		m_Legend.SetMode( 16 );
		m_Graph.SetMode( TRUE );
		}
	UpDateGraph();
	GSClipWrite( 0,0,0,0, CBWMF, 0 );
	GSWinPaint(WPBITMAP);
	GSWinPaint(WPMANUAL);
	if( bBlackWhite )
		{
		m_Graph.SetSymbolSize( 25 );
		m_Legend.SetMode( 0 );
		m_Graph.SetMode( FALSE );
		}
	m_nBKColor = WHITE;
	UpDateGraph();


	//	Get Metafile off of Clipboard.
	OpenClipboard();

	hGMem = GetClipboardData( CF_METAFILEPICT );
	if( hGMem != NULL )
		{
		lpmfp = (LPMETAFILEPICT)GlobalLock( hGMem );
		if( lpmfp != NULL )
			{
			hMetaFile = CopyMetaFile( lpmfp->hMF, NULL );
			if( hMetaFile == NULL )
				{
				GlobalUnlock( hGMem );
				CloseClipboard();
				return;
				}

			nMapMode	= lpmfp->mm;
			nxExt		= lpmfp->xExt;
			nyExt		= lpmfp->yExt;
			dAspect = (double)lpmfp->yExt / (double)lpmfp->xExt;
			GlobalUnlock( hGMem );
			}
		}

	CloseClipboard();

	if( hMetaFile == NULL ) return;

	//	Get # of pixels per inch.
	double dXPixsInch = DC.GetDeviceCaps( LOGPIXELSX );
	double dYPixsInch = DC.GetDeviceCaps( LOGPIXELSY );

	//	Get # of Pixels printer display area.
	double dXRes = DC.GetDeviceCaps( HORZRES );
	double dYRes = DC.GetDeviceCaps( VERTRES );

	//	Get # of mm in printers display area.
	double dXSize = DC.GetDeviceCaps( HORZSIZE );
	double dYSize = DC.GetDeviceCaps( VERTSIZE );

	//	Get # of mm in the graph.
	double dXNumMm = (double)nxExt / 100.0;
	double dYNumMm = (double)nyExt / 100.0;

	//	Get # of pixels per mm.
	double dXPixsMm = dXRes / dXSize;
	double dYPixsMm = dYRes / dYSize;
	
	dYSize -= 12.7;

	double dXRatio = dXSize / dXNumMm;
	double dYRatio = dYSize / dYNumMm;

	//	Get the X,Y extents.
	double dXExt = dXRatio * dXNumMm * dXPixsMm;
	double dYExt = dYRatio * dYNumMm * dYPixsMm;


	DOCINFO	JobInfo;
	memset( &JobInfo, 0, sizeof(DOCINFO) );
    JobInfo.cbSize		= sizeof(JobInfo);
	JobInfo.lpszDocName	= "WQS Graph";
	
	if( DC.StartDoc( &JobInfo ) == -1 )
		TRACE("ERROR: StartDoc\n" );

	if( DC.StartPage() == -1 )
		TRACE("ERROR: StartPage\n" );

	DC.SaveDC() ;
	DC.SetMapMode( nMapMode );
	DC.SetWindowOrg( 0,0);
	DC.SetWindowExt( (int) dXExt, (int)dYExt );
	DC.SetViewportOrg( 0, (int)(dYPixsInch/2.0) );
	DC.SetViewportExt( (int)dXExt, (int)dYExt );
	EnumMetaFile( DC.GetSafeHdc(), hMetaFile, EnumMetaProc, NULL );
	DC.RestoreDC( -1 );
	ReleaseDC( &DC );

	if( DC.EndPage() == -1 )
		TRACE("ERROR: EndPage\n" );

	if( DC.EndDoc() == -1 )
		TRACE("ERROR: EndDoc\n" );
	
	DeleteMetaFile( hMetaFile );
}
/////////////////////////////////////////////////////////////////////////////
 
0
KishorS (3)
3/17/2008 2:54:00 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
640 Views

Similar Articles

[PageSpeed] 40

What does EnumMetaProc do?

Have you tried

DC.PlayMetaFile(hMetaFile,&Rect);

AliR.


"Kishor S" <KishorS@discussions.microsoft.com> wrote in message 
news:EE5E193A-6B27-45CF-AF8F-FCAE0D470EDC@microsoft.com...
> Hi,
>
> I have an MFC code written for printing a graph/document from my 
> application
> to the printer directly. It is identifying the printer, and the document 
> gets
> initialised in the printer spool, but it is not printing.  When i check 
> the
> data size of the spool document it shows 0 bytes!.  As the same time, if i
> try to paste manually the data on Paint, I am getting the required output 
> in
> paint.  ( ie. data is available on the Clipboard but not getting printed)
>
> Can anybody help me in resolving this at the earliest.
>
> Thanks in advance.
> /////////////////////////////////////////////////////////////////////////////
> void CGraphDisplayWnd::PrintGraph( void )
> {
> AssertValid();
>
> GLOBALHANDLE hGMem = NULL;
> LPMETAFILEPICT lpmfp = NULL;
> HMETAFILE hMetaFile = NULL;
> BOOL bBlackWhite= TRUE;
> int nMapMode = 0;
> int nyExt = 0;
> int nxExt = 0;
> double dAspect = 0.0;
> CDC DC;
> PRINTDLG PrintDlg;
> CWQSApp* pApp = GetWQSAppPtr();
>
> if( !pApp->GetPrinterDeviceDefaults( &PrintDlg ) )
> {
> TRACE( "Could not get printer defaults!\n" );
> return;
> }
>
> if( !pApp->CreatePrinterDC( DC ) )
> {
> TRACE( "Could not open the printer!\n" );
> return;
> }
>
> if( PrintDlg.hDevMode != NULL )
> {
> LPDEVMODE DevMode = (LPDEVMODE)GlobalLock( PrintDlg.hDevMode );
> if( DevMode != NULL )
> {
> ASSERT( DevMode != NULL );
>
> if( DevMode->dmColor != DMCOLOR_MONOCHROME )
> bBlackWhite = FALSE;
> }
> GlobalUnlock( PrintDlg.hDevMode );
> }
>
> int nSize = 35;
>
> // Copy Graph to Clipboard.
> GSUseView( m_nGraphNum, 0 );
> GSWinPaint( WPMETAFILE );
> GSWinPaint( WPMANUAL );
> m_nBKColor = LIGHT+WHITE;
> if( bBlackWhite )
> {
> m_Graph.SetSymbolSize( nSize );
> m_Legend.SetMode( 16 );
> m_Graph.SetMode( TRUE );
> }
> UpDateGraph();
> GSClipWrite( 0,0,0,0, CBWMF, 0 );
> GSWinPaint(WPBITMAP);
> GSWinPaint(WPMANUAL);
> if( bBlackWhite )
> {
> m_Graph.SetSymbolSize( 25 );
> m_Legend.SetMode( 0 );
> m_Graph.SetMode( FALSE );
> }
> m_nBKColor = WHITE;
> UpDateGraph();
>
>
> // Get Metafile off of Clipboard.
> OpenClipboard();
>
> hGMem = GetClipboardData( CF_METAFILEPICT );
> if( hGMem != NULL )
> {
> lpmfp = (LPMETAFILEPICT)GlobalLock( hGMem );
> if( lpmfp != NULL )
> {
> hMetaFile = CopyMetaFile( lpmfp->hMF, NULL );
> if( hMetaFile == NULL )
> {
> GlobalUnlock( hGMem );
> CloseClipboard();
> return;
> }
>
> nMapMode = lpmfp->mm;
> nxExt = lpmfp->xExt;
> nyExt = lpmfp->yExt;
> dAspect = (double)lpmfp->yExt / (double)lpmfp->xExt;
> GlobalUnlock( hGMem );
> }
> }
>
> CloseClipboard();
>
> if( hMetaFile == NULL ) return;
>
> // Get # of pixels per inch.
> double dXPixsInch = DC.GetDeviceCaps( LOGPIXELSX );
> double dYPixsInch = DC.GetDeviceCaps( LOGPIXELSY );
>
> // Get # of Pixels printer display area.
> double dXRes = DC.GetDeviceCaps( HORZRES );
> double dYRes = DC.GetDeviceCaps( VERTRES );
>
> // Get # of mm in printers display area.
> double dXSize = DC.GetDeviceCaps( HORZSIZE );
> double dYSize = DC.GetDeviceCaps( VERTSIZE );
>
> // Get # of mm in the graph.
> double dXNumMm = (double)nxExt / 100.0;
> double dYNumMm = (double)nyExt / 100.0;
>
> // Get # of pixels per mm.
> double dXPixsMm = dXRes / dXSize;
> double dYPixsMm = dYRes / dYSize;
>
> dYSize -= 12.7;
>
> double dXRatio = dXSize / dXNumMm;
> double dYRatio = dYSize / dYNumMm;
>
> // Get the X,Y extents.
> double dXExt = dXRatio * dXNumMm * dXPixsMm;
> double dYExt = dYRatio * dYNumMm * dYPixsMm;
>
>
> DOCINFO JobInfo;
> memset( &JobInfo, 0, sizeof(DOCINFO) );
>    JobInfo.cbSize = sizeof(JobInfo);
> JobInfo.lpszDocName = "WQS Graph";
>
> if( DC.StartDoc( &JobInfo ) == -1 )
> TRACE("ERROR: StartDoc\n" );
>
> if( DC.StartPage() == -1 )
> TRACE("ERROR: StartPage\n" );
>
> DC.SaveDC() ;
> DC.SetMapMode( nMapMode );
> DC.SetWindowOrg( 0,0);
> DC.SetWindowExt( (int) dXExt, (int)dYExt );
> DC.SetViewportOrg( 0, (int)(dYPixsInch/2.0) );
> DC.SetViewportExt( (int)dXExt, (int)dYExt );
> EnumMetaFile( DC.GetSafeHdc(), hMetaFile, EnumMetaProc, NULL );
> DC.RestoreDC( -1 );
> ReleaseDC( &DC );
>
> if( DC.EndPage() == -1 )
> TRACE("ERROR: EndPage\n" );
>
> if( DC.EndDoc() == -1 )
> TRACE("ERROR: EndDoc\n" );
>
> DeleteMetaFile( hMetaFile );
> }
> /////////////////////////////////////////////////////////////////////////////
> 


0
AliR3470 (3235)
3/17/2008 2:38:05 PM
See below...
On Sun, 16 Mar 2008 19:54:00 -0700, Kishor S <KishorS@discussions.microsoft.com> wrote:

>Hi,
>
>I have an MFC code written for printing a graph/document from my application 
>to the printer directly. It is identifying the printer, and the document gets 
>initialised in the printer spool, but it is not printing.  When i check the 
>data size of the spool document it shows 0 bytes!.  As the same time, if i 
>try to paste manually the data on Paint, I am getting the required output in 
>paint.  ( ie. data is available on the Clipboard but not getting printed)
>
>Can anybody help me in resolving this at the earliest.
>
>Thanks in advance.
>/////////////////////////////////////////////////////////////////////////////
>void CGraphDisplayWnd::PrintGraph( void )
>	{
>	AssertValid();
>
>	GLOBALHANDLE	hGMem	= NULL;
>	LPMETAFILEPICT	lpmfp	= NULL;
>	HMETAFILE	hMetaFile	= NULL;
>	BOOL		bBlackWhite= TRUE;
>	int		nMapMode	= 0;
>	int		nyExt	= 0;
>	int		nxExt	= 0;
>	double		dAspect	= 0.0;
>	CDC		DC;
>	PRINTDLG		PrintDlg;
****
Why not use CPrintDialog?
****
>	CWQSApp* pApp = GetWQSAppPtr();
****
This is scary.  What is some display window doing storing or using information in the app?

Note that a global variable by any other name is still a global variable, and still bad
style.
****
>
>	if( !pApp->GetPrinterDeviceDefaults( &PrintDlg ) )
>		{
>		TRACE( "Could not get printer defaults!\n" );
>		return;
>		}
>
>	if( !pApp->CreatePrinterDC( DC ) )
>		{
>		TRACE( "Could not open the printer!\n" );
>		return;
>		}
>
>	if( PrintDlg.hDevMode != NULL )
>		{
>		LPDEVMODE DevMode = (LPDEVMODE)GlobalLock( PrintDlg.hDevMode );
>		if( DevMode != NULL )
>			{
>			ASSERT( DevMode != NULL );
>
>			if( DevMode->dmColor != DMCOLOR_MONOCHROME )
>				bBlackWhite = FALSE;
>			}
>		GlobalUnlock( PrintDlg.hDevMode );
>		}
****
I would be tempted to eliminate all the above code and just call CPrintDialog::DoModal()
****
>
>	int nSize = 35;
>	
>	//	Copy Graph to Clipboard.
>	GSUseView( m_nGraphNum, 0 );
>	GSWinPaint( WPMETAFILE );
>	GSWinPaint( WPMANUAL );
>	m_nBKColor = LIGHT+WHITE;
>	if( bBlackWhite )
>		{
>		m_Graph.SetSymbolSize( nSize );
>		m_Legend.SetMode( 16 );
>		m_Graph.SetMode( TRUE );
>		}
>	UpDateGraph();
>	GSClipWrite( 0,0,0,0, CBWMF, 0 );
>	GSWinPaint(WPBITMAP);
>	GSWinPaint(WPMANUAL);
>	if( bBlackWhite )
>		{
>		m_Graph.SetSymbolSize( 25 );
>		m_Legend.SetMode( 0 );
>		m_Graph.SetMode( FALSE );
>		}
>	m_nBKColor = WHITE;
>	UpDateGraph();
>
>
>	//	Get Metafile off of Clipboard.
>	OpenClipboard();
****
I find this very peculiar.  Why does printing a document modify the clipboard?  This is
not just exceptionally bad style, it is in violation of every known standard for clipboard
management that exists.
****
>
>	hGMem = GetClipboardData( CF_METAFILEPICT );
>	if( hGMem != NULL )
>		{
>		lpmfp = (LPMETAFILEPICT)GlobalLock( hGMem );
>		if( lpmfp != NULL )
>			{
>			hMetaFile = CopyMetaFile( lpmfp->hMF, NULL );
>			if( hMetaFile == NULL )
>				{
>				GlobalUnlock( hGMem );
>				CloseClipboard();
>				return;
>				}
>
>			nMapMode	= lpmfp->mm;
>			nxExt		= lpmfp->xExt;
>			nyExt		= lpmfp->yExt;
>			dAspect = (double)lpmfp->yExt / (double)lpmfp->xExt;
>			GlobalUnlock( hGMem );
>			}
>		}
>
>	CloseClipboard();
>
>	if( hMetaFile == NULL ) return;
>
>	//	Get # of pixels per inch.
>	double dXPixsInch = DC.GetDeviceCaps( LOGPIXELSX );
>	double dYPixsInch = DC.GetDeviceCaps( LOGPIXELSY );
>
>	//	Get # of Pixels printer display area.
>	double dXRes = DC.GetDeviceCaps( HORZRES );
>	double dYRes = DC.GetDeviceCaps( VERTRES );
>
>	//	Get # of mm in printers display area.
>	double dXSize = DC.GetDeviceCaps( HORZSIZE );
>	double dYSize = DC.GetDeviceCaps( VERTSIZE );
>
>	//	Get # of mm in the graph.
>	double dXNumMm = (double)nxExt / 100.0;
>	double dYNumMm = (double)nyExt / 100.0;
>
>	//	Get # of pixels per mm.
>	double dXPixsMm = dXRes / dXSize;
>	double dYPixsMm = dYRes / dYSize;
>	
>	dYSize -= 12.7;
***
What is the derivation of this magical value?
****
>
>	double dXRatio = dXSize / dXNumMm;
>	double dYRatio = dYSize / dYNumMm;
>
>	//	Get the X,Y extents.
>	double dXExt = dXRatio * dXNumMm * dXPixsMm;
>	double dYExt = dYRatio * dYNumMm * dYPixsMm;
>
>
>	DOCINFO	JobInfo;
>	memset( &JobInfo, 0, sizeof(DOCINFO) );
>    JobInfo.cbSize		= sizeof(JobInfo);
>	JobInfo.lpszDocName	= "WQS Graph";
>	
>	if( DC.StartDoc( &JobInfo ) == -1 )
>		TRACE("ERROR: StartDoc\n" );
>
>	if( DC.StartPage() == -1 )
>		TRACE("ERROR: StartPage\n" );
>
>	DC.SaveDC() ;
>	DC.SetMapMode( nMapMode );
>	DC.SetWindowOrg( 0,0);
****
Seems redundant because the window original is already 0,0
****
>	DC.SetWindowExt( (int) dXExt, (int)dYExt );
>	DC.SetViewportOrg( 0, (int)(dYPixsInch/2.0) );
>	DC.SetViewportExt( (int)dXExt, (int)dYExt );
>	EnumMetaFile( DC.GetSafeHdc(), hMetaFile, EnumMetaProc, NULL );
****
Since you didn't show EnumMetaProc, how are we supposed to guess what it does?  

By the way, having actually implemented a very thorough EnumMetaProc, I can tell you that
the documentation is confusing, very incomplete, and in some cases blatantly incorrect. So
how did you handle all the cases of enumeration, and what do you do with each of them? Are
you certain you handled every possible case in every possible way?   Note that
EnumMetaFile does not actually do any printing!  It merely hands you each metarecord, and
it is up to you to do something with each of them.  So the most important function you
could show (none of the rest of this code really matters!) is completely omitted!

You can take a look at my Metafile Explorer, where among other things I give links to all
the erroneous and/or incomplete documentation dealing with metafiles.
				joe
****
>	DC.RestoreDC( -1 );
>	ReleaseDC( &DC );
>
>	if( DC.EndPage() == -1 )
>		TRACE("ERROR: EndPage\n" );
>
>	if( DC.EndDoc() == -1 )
>		TRACE("ERROR: EndDoc\n" );
>	
>	DeleteMetaFile( hMetaFile );
>}
>/////////////////////////////////////////////////////////////////////////////
> 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/23/2008 11:56:21 PM
Thanks Joseph

I have modified the code as given below, now it works fine !

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

if (UpdateData(TRUE))
{
 DOCINFO di;
 if (DC)
 {
  ZeroMemory( &di, sizeof(DOCINFO));
  di.cbSize = sizeof(DOCINFO);
  di.lpszDocName = "WQS Graph";
  if (SP_ERROR != :tartDoc(DC, &di))
  {
   :tartPage(DC);
   if (IsClipboardFormatAvailable(CF_METAFILEPICT))
   {
    GLOBALHANDLE    hGMem ;
    LPMETAFILEPICT    lpMFP ;
    OpenClipboard() ;
    hGMem = GetClipboardData(CF_METAFILEPICT) ;
    lpMFP = (LPMETAFILEPICT)GlobalLock(hGMem) ;
    DC.SaveDC() ;
    DC.SetMapMode(lpMFP->mm) ;
    DC.SetWindowOrg( 0,0);
    DC.SetWindowExt( (int) dXExt, (int)dYExt );
    DC.SetViewportOrg( 0, (int)(dYPixsInch/2.0) );
    DC.SetViewportExt((int)dXExt, (int)dYExt) ;
    DC.PlayMetaFile(lpMFP->hMF) ;
    VERIFY(DC.RestoreDC(-1)) ;
    GlobalUnlock(hGMem) ;
    CloseClipboard() ;
   }
   ::EndPage(DC);
   ::EndDoc(DC);
  }
 }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


0
KishorS (3)
3/24/2008 2:37:01 AM
Pls. find the code of  EnumMetaProc below:

int CALLBACK EnumMetaProc( HDC hDC, HANDLETABLE FAR *lpHTable, METARECORD 
FAR *lpMFR, int nObj, LPARAM /*lpClientData*/ )

{
return PlayMetaFileRecord( hDC, lpHTable, lpMFR, nObj );
}

Best Regards

 

0
KishorS (3)
3/24/2008 2:43:01 AM
Reply:

Similar Artilces:

Using 2003 runtime, Access 2007 installed...
Hi Dumb-ish question:- Is it possible to run an Access ADE under the 2003 runtime, if Office 2007 is already installed on the PC? All help gratefully received. TIA Steve "CyberDwarf" <sdi@lineone.net> wrote: >Is it possible to run an Access ADE under the 2003 runtime, if Office 2007 >is already installed on the PC? Yes. This assumes that the version of Office 2007 does not contain Access 2007. Tony -- Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can read the entire thread of messages. Microsoft Access Links, ...

How do I print a list of the directory contents
I need to print the disk directory contents. In DOS this was possible. Is it possible in WORD? Thanks No - but you could use the freeware Printfolders utility you can download from my web site that will produce a text listing that you can open in Word. -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <...

Running a PIF file using CreateProcess in an allocated console window
Hello, I am trying to find a way to execute a pif file within the context of my own application's console using AllocConsole. My basic need is to have the console in my context so I can use the console API's AND I must use the pif parameters for EMS, XMS, and a few other parameters. Is there a way to do this ? Is there a way around ? For example, try running "start /b XX.pif" I am getting an error message The NTVDM CPU has encountered an illegal instruction. and get the Close Ignore buttons. This is not related to any problems in the DOS application. If I use CREATE_...

printing copies
under print options: Number of copies___. It will only print out 1 copy. I say 5 and it still prints out 1. I am a new user of 2007 Excel I suspect the problem is with the printer. Try getting the newest driver best wishes -- Bernard V Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme remove caps from email "Val in Texas" <Val in Texas@discussions.microsoft.com> wrote in message news:78A83505-189A-4731-AF25-CD5505E33510@microsoft.com... > under print options: Number of copies___. It will only print out 1 copy. > I > say 5 and it still prints out 1. ...

Ghosted print and print preview
Hello everyone, I have a problem with printing in excel. The print and print preview options appear ghosted. I still can print through the print icon on the toolbar. Any suggestions??? Martin ...

Macro for blocker from using cell range
Is there a way to write code that can unlock a worksheet (w/password) allowing the user access to functionality while relocking (w/password) the worksheet should the user mouse click or move into a range of cells that would normally be locked? Assistance and a learning opportunity is always appreciated... Regards, Lenny With "qwerty" as defined name for range =Sheet1!$A$1:$F$12,Day!$A$26:$F$34 Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim myrange As Range Set myrange = Me.Range("qwerty") On Error GoTo ws_exit: Applica...

Using VBA to select Items in multiselect Listbox
How can you programatically select items in a multiselect list box based on their lables? Certain groups of items in my multiselect listbox will be frequently selected together. I want to have check boxes elsewhere on the form that a user can click that will cause a group of items to be selected in the list box. The list box itself is used to make an sql statement. Thanks. Marcie "bymarce" <bymarce@discussions.microsoft.com> wrote in message news:FF7548C3-FBE9-498B-9455-6EE50A8F2E17@microsoft.com... > How can you programatically select items in a mult...

Print Dynamic Range
I have a basic excel template used for ordering parts. It runs from A1:N250 and I can print easily repeating rows 1:11 on each page (contains job details) . Trouble is sometimes there may only be 10 part numbers requiring only first page and I finish up throwing away trees by printing entire sheet! I know I can reset print area each time am setting this up on Sharepoint for multi users and need a macro/button to recognise number of items and print accordingly. Any help greatly appreciated -- Message posted via http://www.officekb.com Sub SetPrintArea() 'change this cons...

TCP/IP printing
Hello, I have a networking question. I have a print device with a static IP address on one network. A computer on another network can connect to the printer (NBT is enabled and so is LPR) and the drivers are installed but cannot print. I know this is correct behavior but want to know in detail why it seems to half work. I am guessing it has to do with port 138,139 and 515 but not positive. Probably a better question to ask a networking forum but hey. Thanks can you access the printer through the printer IP address? -- ashvin :D Just chill -pls post your feedback on...

MANUAL-reset events must be used here?
HI, All "When performing multiple simultaneous overlapped operations, the calling thread must specify an OVERLAPPED structure with a different manual-reset event object for each operation." -------MSDN,"Platform SDK: DLLs, Processes, and Threads: Synchronization and Overlapped Input and Output" Why a MANUAL-reset event object is requested here?can it be an AUTOMATIC-reset one?what's the different between these two here? thank you. i don't know, but have you tried both types of events to see the result. If they both work then I wouldn't worry about it. &...

Printing booklet
I am producing a 50 to 60 page booklet using Pubisher 2003. The page format will be using 8.5 x 11 paper folded in half. I need to print both sides of the paper. How do I print the booklet so that I print half the project on one side of the paper and the other half on the back. Will publisher keep track of the pages so that for example; that page 2 and page 50 print on the same side/sheet of paper so when all pages are printed, folded and bound the book reads correctly. Thanks John Houston, Tx more info...I am using a single side printer so I have to run the pages through twice ...

Help with compile error MS S using MT and clr
Help!, I need to compile this code with static libs so it run on another XP machine that does'nt have MS Studio installed. When I compile now I get an ERROR: 1>------ Rebuild All started: Project: drawing_control, Configuration: Release Win32 ------ 1>Deleting intermediate and output files for project 'drawing_control', configuration 'Release|Win32' 1>Compiling... 1>cl : Command line error D8016 : '/MT' and '/clr:oldsyntax' command-line options are incompatible 1>Build log was saved at "file://c:\Documents and Settings\Grant\Desktop\dra...

Check printing in GP 7.0
Dear Guys, I have check payments for vendors, where I'm dealing with LOCAL CURRENCY & FORIGHN CURRENCY. When I paid by check in LOCAL CURRENCY then the amount in words prints perfectly but if i paid by check in FORIGN CURRENCY then the amount in word prints in numeric which i want to print amount in words instead of numbers. Please help me to print checks amount in words for FORIGN CURRENCY as well. Your suggestion would be appricated on above issue thnx Shamin ...

How do I stop my Publisher 2003 document from saving as a webpag.
When I save a particular publication ( a newsletter) in Publisher 2003 as a Publisher 2000 document (so I can work on it elsewhere) it opens as a web page instead of a print document. When I convert it back to print, I lose a few inches of print on the left page that just don't print even when I change the margins. The missing print shows on the screen normally, it is only in print preview and on paper that it cuts off. Can I stop this from happening? Can I retrieve the missing print? Please help! You may have to reconstruct this publication. -- Mary Sauer MSFT MVP http://off...

Excel BUG (All Versions) Excel Macro Margins using Print Preview
Where can i post this BUG? (Excel Macro Margins using Print Preview) Is there an Excel BUG reporting site? Steps: 1) New worksheet, write something in it 2) Start recording a new macro 3) File -> Print Preview 4) Click on the Margins Button, the page margins will appear, so that you can visually change and move them 5) Set one or more margins 6) Close the Print Preview 7) Stop the Macro What happened is that in the VBA code there will be writtenthe following lines: ..LeftMargin = Application.InchesToPoints(0.91) ..RightMargin = Application.InchesToPoints() Where in second line ther...

"Tiled" print setting.
I just want the page that I designed to print on one page! I can't change the print setting "tiled" and as it is, it's printing on four pages all broken up. It is possible that you have created your document on a paper size that is not supported by your printer. Try changing your paper size to 8 1/2 by 11 and see if the print options are more to your liking. "MissMarple" <MissMarple@discussions.microsoft.com> wrote in message news:A6776BEA-37EE-4645-B389-866A6CDB2D96@microsoft.com... >I just want the page that I designed to print on one ...

CHtmlView and Printing
Hi Everyone, The CHtmlView is giving me alot of head aches. Here is what I am doing. I am opening an XML file (being formatted using XLST) in a hidden CHtmlView and printing it. Here is how the process goes: 1. I create the XML file on the fly. 2. load the XML file in to CHtmlView. 3. Once loaded I tell it to print the resulting HTML page. 4, I need to delete XML file after the printing is done. (this is the problem). I can't figure out how to find out when the CHtmlView is done printing. CHtmlView::OnFilePrint is asynchronous. And CHtmlView doesn't tell me that it is currently p...

Problems with printing
Dear all I have an application, which has been working without problems for the last 7 years. The application has some printing capabilities. Now, we have just gotten a new printer (HP Laserjet CM4370), and when I try to print, my application crashes. The app crashes in the print setup dialog even before I press OK. If I select any other printer as default printer, the app doesn't crash. Then I can show the print setup dialog without problems. But then, when I select the CM4370, the app crashes again, even if I do not press OK. Even if I choose to not show the print setup dialog, and j...

Printing--How not to Print Bkground
In my wrksht there is a cell range highlighted with an autofill color. We use this to show the user where to enter the data. Is there anyway to avoid printing this background color. We want to keep the color in the cell range in our wrksht but we dont want it printed. Hi Jeff, have you tried Print preview, Setup, Sheet, Black & white? Gilles "Jeff" <anonymous@discussions.microsoft.com> wrote in message news:001201c3ba81$023b8af0$a301280a@phx.gbl... > In my wrksht there is a cell range highlighted with an > autofill color. We use this to show the user where t...

Printing in Vista
After each document prints another sheet prints which has the filename, directory,title, subject, author, creation date, last saved on, total editing time, last printed on. These are just some of the items that print on this one sheet of paper. Can anyone help me? In your Print dialog, uncheck "Document Properties." On Nov 30, 1:34=A0pm, peppermint patty <peppermint pa...@discussions.microsoft.com> wrote: > After each document prints another sheet prints which has the filename, > directory,title, subject, author, creation date, last saved on, total edi= ti...

How do you customize the 'Print View'?
Ho do you customize the print view of the different type of records? TIA Antony On Apr 24, 5:09 pm, "Antony" <info AT webpc DOT biz> wrote: > Ho do youcustomizetheprintviewof the different type of records? > TIA > Antony You are probably going to need to create a custom SQL Server Report to get what you need. Or you can create a mail merge via MS word and access a CRM Table or View using ODBC. Post what you need exactly and you might get some more specific direction, or possibly someone has what you need already. Scott Moore www.easiintl.com ...

College Student Economics and Statistics Graph/Equation Tutorial .
I am having trouble grahing Opportunity Lines and Possibilty Curves in Excel. These will be important and useful skills and I have been/will be using Excel alot in my career. There seems to be lack of simple step-by-step tutorials for intergrating basic, university level economic and statisic equations into graphs. The few linear equation graphing tutorials for the Analysis Pac and Solver Add-ins that I have found are very hard to understand, and usually jump to a much higher level understanding (for a student in a 200 level course). I have no idea what competency a "200 level cou...

Printing problem
I have Window 7 Home Premium. I have Microsoft Office 2010 beta. I have HP LaserJet P1005 printer. Here is my problem: Printing from Word document to 8.5 x 11" size paper no problem. But I can not print any size of envelopes or custom setup paper size. I cannot print anything from Microsoft Publisher 2010 (Beta). Does any one know how to fix? There is a driver for your printer with a 11-2009 timestamp on the HP site, maybe newer than the one you have now. http://h10025.www1.hp.com/ewfrf/wc/softwareList?os=4062&lc=en&dlc=en&cc=us&lang=en&produ...

Area under graph
Does anyone know how I can get the area under the curve for a graph I've created? Hi Mike, Check out Bernard's examples of how to implement Trapezoid and Simpson Rules www.stfx.ca/people/bliengme/ExcelTips Mike wrote: > Does anyone know how I can get the area under the curve > for a graph I've created? -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info Do you know the functional form of the curve? Many curves (for example polynomials) can be analytically integrated after estiimating a few parameters. Cubic splines approximates the chart line smoother i...

Print a report without displaying print preview
Hi, Please can someone tell me in a really basic way how can I print a report WITHOUT it also previewing. I'm using 2007 I have several forms which have a print button ( created with the command button wizard, report operations, print report, then relevant report is chosen to print). This works great, and prints the relevant report for the the associated record, however when you click the print button it also displays the print preview and doesn't close it again. This means that until the preview is closed the same thing keeps printing when the button is clicked....