Print vba

I'm no vba expert, but with a little knowledge you can put together some very handy tools that others can easily edit. To help out I have attached the vba I use.

Basically, all I do is use forms and keyins to run my printing. As, on many occasions, I do the initial setup for firms and they manage once installed, I try and keep things simple. For this reason I use a pltcfg for each printer. This means that once I have one in place all the have to do is copy one of the existing pltcfg files and rename it for the new printer, I also force the printer name in the pltcfg as well as I have found using the default printer problematic.

In the build, users have 2 buttons for setting the floor and opening the print form:

The way Siteprint works is that the user pics which floor they are on using set floor:

All this does is set a config variable in the users ucf files which is read by the Siteprint and decides which floor form to open.

The button code is:

Private Sub CommandButton3_Click()
CadInputQueue.SendKeyin "expand setsave FLR_LVL = 1010"
End Sub

Once the floor has been selected the user hits the print button and the vb opens the correct form for that users floor. I've added a few nicities to detect if a sheet outline is in the files and if not then it looks for a fence. Is no fence exists it errors out and asks the user to place a fence first. You could change that to have a place fence button which I have for some builds.

The code is a series of 'if 'then' statements which looks like:

If flr = 1010 Then
Level_10_Printing.Show
If ActiveDesignFile.Fence.IsDefined = True And _
ActiveModelReference.Type = msdModelTypeSheet Then
bndy = Fence
ElseIf ActiveDesignFile.Fence.IsDefined = True And _
ActiveModelReference.Type = msdModelTypeNormal Then
bndy = Fence
ElseIf ActiveModelReference.Type = msdModelTypeSheet And _
ActiveModelReference.GetSheetDefinition.IsEnabled = True Then
bndy = sheet
ElseIf ActiveDesignFile.Fence.IsDefined = False And _
ActiveModelReference.Type = msdModelTypeNormal Then
MsgBox "Please Place a Fence Before Printing - 1"
Level_10_Printing.Hide
ElseIf ActiveModelReference.Type = msdModelTypeSheet And _
ActiveModelReference.GetSheetDefinition.IsEnabled = False Then
MsgBox "Please Place a Fence Before Printing - 2"
Level_10_Printing.Hide

End If

Once selected, the form opens with the available printers:

With printing it's pretty easy to use the vb with keyins to achieve what you want. In most of my builds I build in the hard copy print and the pdf each time you print, makes it much easier for the user. This looks like:

Private Sub CommandButton1_Click()
copies = (Level_10_Printing.copylist.Value)
CadInputQueue.SendKeyin "print driver STD_PLTDRV:Delta_1_PCL.pltcfg;print colormode color;print pentable attach STD.tbl;print units mm;print boundary " + bndy
CadInputQueue.SendKeyin "print copies " + copies + ";print maximize;print execute"
CadInputQueue.SendKeyin "print driver STD_PLTDRV:STD_PDF.pltcfg;print colormode color;print pentable attach STD.tbl;print units mm;print boundary " + bndy
CadInputQueue.SendKeyin "print maximize;print execute"
Level_10_Printing.Hide
End Sub

To help the users there is also an option for multi prints. Once a print has been sent the form just closes.

As I said at the start, this is a pretty basic way of using vb, but one anyone can pick up without needing too much knowledge.

Anonymous