davieboy_xr
04-15-2004, 06:32 AM
I have a mshflexgrid, i need to to print it out horizontal is there a way i can do this?Also id there anyway of formatting the page with headers and footers.
thanks dave
thanks dave
printing mshflexgriddavieboy_xr 04-15-2004, 06:32 AM I have a mshflexgrid, i need to to print it out horizontal is there a way i can do this?Also id there anyway of formatting the page with headers and footers. thanks dave Flyguy 04-15-2004, 06:34 AM Have a look at the .. thread in the Code Library MKoslof 04-15-2004, 06:35 AM http://www.xtremevbtalk.com/showthread.php?t=35110 A good place to start. Look at the code sample regarding printing the Grid EDIT: DOH!..too slow :) davieboy_xr 04-15-2004, 06:39 AM ok thanks guys davieboy_xr 04-15-2004, 06:48 AM i get a runtime error when i click preview on the form - runtime error -380 ,invalid property value, and when i go to debug it stops at Printer.Orientation = NewOrientation Public Property Let PrinterOrientation(ByVal NewOrientation As pgOrientation) m_lPrinterOrientation = NewOrientation Printer.Orientation = NewOrientation End Property MKoslof 04-15-2004, 06:55 AM Where do you iniatilize the actual class..you need something like this, in a "command print event" etc. Dim newMarginTop As Long Dim newMarginLeft As Long Dim lNofPages As Long ' set the margin newMarginTop = 1250 newMarginLeft = 400 'set and run the class variables Set printClass = New PrintGrid Set printClass.Destination = Printer Set printClass.Source = Form1.MSFlexGrid1 printClass.MarginTop = newMarginTop printClass.MarginLeft = newMarginLeft printClass.PrinterOrientation = pgoLandscape printClass.PrintGridLines = True lNofPages = printClass.PrintGrid Set printClass = Nothing davieboy_xr 04-15-2004, 06:57 AM sorry i forgot to mention that im looking at flyguys method of printing a grid: http://www.xtremevbtalk.com/attachment.php?attachmentid=2592 MKoslof 04-15-2004, 07:01 AM Right and I am basing this code off this exact class. I might have modified it slightly, for my own needs..but see, I am passing all the parameters I need. First set a new instance of the PrintClass. Then, pass to each property the values you want...as I have done in the code above. davieboy_xr 04-15-2004, 07:14 AM ok im with u now... i have put the code into a button and added the class from flyguys program into my program : Private Sub cmdPrint_Click() Dim newMarginTop As Long Dim newMarginLeft As Long Dim lNofPages As Long ' set the margin newMarginTop = 1250 newMarginLeft = 400 'set and run the class variables Set printClass = New PrintGrid Set printClass.Destination = Printer Set printClass.Source = msh printClass.MarginTop = newMarginTop printClass.MarginLeft = newMarginLeft printClass.PrinterOrientation = pgoLandscape printClass.PrintGridLines = True lNofPages = printClass.PrintGrid Set printClass = Nothing End Sub but im now getting a 'user type not defined on:New PrintGrid MKoslof 04-15-2004, 07:24 AM What is the name of your Class? The one I am using is called "PrintGrid". So, I then set a new instance of it. You need to set a new instance of your class name.. davieboy_xr 04-15-2004, 07:35 AM the name of the class is printgrid.. i got rid of this error by saving into the project. but now i get a 'variable not difined on set printclass MKoslof 04-15-2004, 07:38 AM Are you using a class module? Save the print grid code within a class module. Then at the top of your Form or module you need to instantiate the object: Dim WithEvents printClass As PrintGrid davieboy_xr 04-15-2004, 07:40 AM a ha... i just figured that one out ;) lol.. MKoslof 04-15-2004, 07:43 AM Good luck ! :) davieboy_xr 04-15-2004, 07:50 AM thanks MKoslof davieboy_xr 04-15-2004, 09:00 AM im getting an type mismatch error on Set printClass.Source = msh, when i hover over the msh i get " "how can i get round this? MKoslof 04-15-2004, 09:19 AM pass in the form reference, so that the code knows which FlexGrid you are talking about..such as (Say MSH is your MSHFlexGrid on Form1) Set printClass.Source = Form1.MSH davieboy_xr 04-15-2004, 09:23 AM ok ive done that and it seems to be looking in the first cell of the grid, its still comming up with a type mismatch MKoslof 04-15-2004, 09:26 AM What does your source property look like in the Class module, is it this? Public Property Set Source(NewGrid As MSFlexGrid) Set m_oFG = NewGrid End Property Notice, the default parameter is MSFLEXGRID. So, since you are passing in a MSHFlexGrid, you are getting a type mismatch :). You need to modify this.... davieboy_xr 04-15-2004, 09:53 AM could i set "m_oFG" as a public variable in the class and then say msh =m_oFG? MKoslof 04-15-2004, 10:13 AM Well, in all honesty, I am not sure if FlyGuy's print grid will work with the MSHFlexGrid, though it should. You might need to build your own class off of his example. I tend to only use the FlexGrid, so any Grid printing classes I have based off of his example won't be exactly the same as yours. What you should do initially is simply change the parameter to an MHSFlexGrid and see what happens: Public Property Set Source(NewGrid As MSHFlexGrid) Set m_oFG = NewGrid End Property Then pass in your Form1.MSH command again davieboy_xr 04-15-2004, 04:13 PM it does work...if you change it to mshflexgrid.. but i now need it to print horizontal.. is there i can do this MKoslof 04-15-2004, 04:42 PM just modify your page orientation properties...landscape or portrait. Or tweak the initial top and left margins, etc. davieboy_xr 04-15-2004, 04:47 PM it stops at the Printer.Orientation = NewOrientationinside the class public Property Let PrinterOrientation(ByVal NewOrientation As pgOrientation) m_lPrinterOrientation = NewOrientation Printer.Orientation = NewOrientation End Property do i need to add a reference? MKoslof 04-16-2004, 06:06 AM What is new orientation? A printer object only takes two orientations by default, portrait and landscape. Where have you defined this new orientation type..this would take quite a bit of coding. |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum