Category Archives: VB

How to disable “Printing x of y” dialog when using the printer object

I have a new process that prints several hundred documents via a batch, but I don’t want the dialog to pop up every time it starts a new file.  This is really annoying as I might be typing in another window and the “Printing” dialog pops up as I’m hitting the spacebar and it thinks I want to cancel printing the document.

You can get around this by making a dummy print controller.

‘This was already declared earlier in the process
MyDocument = New PrintDocument()
Dim dlgPrintingDialog As New StandardPrintController
MyDocument.PrintController = dlbPrintingDialog

That’s it – now you can print and you won’t see a pop-up.

Create MS MDB without MS Access

(from http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=1089)

//Set a COM Reference to “Microsoft ADO Extensions for DDL and Security” (ADOX)

private ADOX.Catalog cat = new ADOX.Catalog();
private ADOX.Table tbl = new ADOX.Table();
private string db_file_path;
db_file_path = ActiveWorkbook.Path + “\\abc.mdb”;
//connect to the Access database
cat.ActiveConnection = “Provider=Microsoft.Jet.OLEDB.4.0;” + “Data Source=” + db_file_path;

//Create a table
tbl.Name = “Prospects”;
// First, fields are appended to the table object
// Then the table object is appended to the Tables collection
tbl.Columns.Append “Name”, adVarWChar;
tbl.Columns.Append “Company”, adVarWChar;