Cheval


Does anyone know what are all the available registry settings for MODI

Through much searching in google (msn search finds nothing) I've found the following the following

' Write to File Only (uses current save folder and Note####.mdi as file name)
SetKeyValue HKEY_CURRENT_USER, "Software\Microsoft\Office\11.0\MODI\MDI Writer", "PrivateFlags", 1, REG_DWORD

' Don't Show Popup Window
SetKeyValue HKEY_CURRENT_USER, "Software\Microsoft\Office\11.0\MODI\MDI Writer", "OpenInMODI", 0, REG_DWORD

'Set persistent annotations
SetKeyValue HKEY_CURRENT_USER, "Software\Microsoft\Office\11.0\MODI\MDI Writer", "BurnInAnnotations", 5, REG_DWORD




Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

MS ISV Buddy Team


Per our support engineer:

Thanks for using Microsoft ISV Community Forum, according your question, since the registry settings of MODI are only for application internal usage, I don¡¯t think there is a complete list and description for all the entries. Following is a list I collected for you which contains as much MODI registry entries as I can find:

Under HKCU\Software\Microsoft\Office\11.0\MODI\MDI Writer\

PrivateFlags

This will be 0 for MDI Format and 16 (decimal) for TIFF format

TIFDPI

Controls the DPI for the TIFF format, allowed values are (in decimal) 100, 200 and 300

COMPIMGEMF

1 for compressing images in the document, 0 for not

DefaultFolder

Default output folder

OpenInMODI

Controls whether or not show the image in ¡°Microsoft office document imaging¡± after the printout is done. If the value is 1 the ¡°Microsoft office document imaging¡± will show up, if it¡¯s 0 it will not.

Public_Orientation

Control the page orientation, 1 for Portrait, 2 for Landscape.

Public_PaperSize

Controls the page size

-brenda (ISV Buddy Team)







Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

Cheval

Thanks Brenda,

It's a shame there wasn't one for setting file output file name...

I'll work with this anyway.

Thanks again.





Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

Fred Hommel

Setting PrivateFlags to 1 will make Note.mdi be "printed" in the current default folder.
PrivateFlags of 17 will make Note.tif print in the default folder.

On TIFDPI I've also seen 600 and 2400 work.

Here's some C# code for playing with it, CoverLetter is a CrystalReport report.

    private CoverLetter CoverLetter1;
    private int iMODICOMPIMGEMF;
    private string sMODIPath;
    private int iMODIPrivateFlags;
    private int iMODIPublic_Orientation;
    private int iMODIPublic_PaperSize;
    private int iMODITIFDPI;
    private int iMODIOpenInMODI;

    private string sMODIKey = @"HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\MODI\MDI writer";
    private void SaveMODIKeys()
    {
      iMODICOMPIMGEMF = (int) Microsoft.Win32.Registry.GetValue(sMODIKey, "COMPIMGEMF", 0);
      sMODIPath = (string) Microsoft.Win32.Registry.GetValue(sMODIKey, "DefaultFolder", @"C:\");
      iMODIPrivateFlags = (int) Microsoft.Win32.Registry.GetValue(sMODIKey, "PrivateFlags", 0);
      iMODIPublic_Orientation = (int)Microsoft.Win32.Registry.GetValue(sMODIKey, "Public_Orientation", 1);
      iMODIPublic_PaperSize = (int)Microsoft.Win32.Registry.GetValue(sMODIKey, "Public_PaperSize", 1);
      iMODITIFDPI = (int) Microsoft.Win32.Registry.GetValue(sMODIKey, "TIFDPI", 300);
      iMODIOpenInMODI = (int)Microsoft.Win32.Registry.GetValue(sMODIKey, "OpenInMODI", 1);
    }

    private void SetMyMODIKeys()
    {
      Microsoft.Win32.Registry.SetValue(sMODIKey, "COMPIMGEMF", 1);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "DefaultFolder", @"C:\temp");
      Microsoft.Win32.Registry.SetValue(sMODIKey, "PrivateFlags", 17);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "Public_PaperSize", 1);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "Public_Orientation", 1);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "TIFDPI", 300);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "OpenInMODI", 0);
    }

    private void RestoreMODIKeys()
    {
      Microsoft.Win32.Registry.SetValue(sMODIKey, "COMPIMGEMF", iMODICOMPIMGEMF);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "DefaultFolder", sMODIPath);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "Public_Orientation", iMODIPrivateFlags);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "Public_PaperSize", iMODIPublic_Orientation);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "Public_PaperSize", iMODIPublic_PaperSize);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "TIFDPI", iMODITIFDPI);
      Microsoft.Win32.Registry.SetValue(sMODIKey, "OpenInMODI", iMODIOpenInMODI);
    }
    private void btnPrint_Click(object sender, EventArgs e)
    {
      try
      {
        SaveMODIKeys();
        SetMyMODIKeys();
        CoverLetter1.PrintOptions.PrinterName = "Microsoft Office Document Image Writer";
        CoverLetter1.PrintToPrinter(1, false, 1, 1);
		// Note.tif will now be in c:\temp. If Note.tif already existed, the MODI printer adds numbers: Note0001.tif and up.
      }
      catch
      {
      }
      finally
      {
        RestoreMODIKeys();
      }
    }





Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

Fred Hommel

Here's some more values that the driver is looking for, can you ask after them also, please

WordNoPrompt
SavedFileRoot
FAXOnly

If FAXOnly is defined as 1, then it looks for:

FAXDPI

SavedFileRoot seems to set the root of the printed name where the save as box is popped up with PrivateFlags set to 1 (mdi) or 17 (tif).





Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

flavio2007

Hi,

I have tried to set the OpenInMODI to 0(zero) to prevent the Microsoft Office document imaging" from opening, but still opens after the printing is done. how can I correct this






Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

Fred Hommel

Hi,

What version of Office

You'll have to change the "version number" in the registry path for the version of Office installed.

12 would be 2007, so the path would be: "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\MODI\MDI writer" for Office 2007.

HTH,

Fred





Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

Cringing Dragon

Does anyone know of a way to override or change these printer driver settings through Visual Basic for Applications without directly modifying the registry

I am using the Microsoft Office Document Image Writer in an Excel VBA script (nothing fancy, simply printing a preset range of sheets to a .mdi file). I want the MODI writer dialog box to appear so that the user can choose their own filename, but I would like it to default to a particular folder. This is an easy setting manually, via the printing preferences for the MODI printer, however this is to be used by many users on many PCs so I would prefer the setting to be (preferably) overridden by the VBA code, or if necessary changed by the VBA code (either will do but if there is a choice I would rather the new settings apply only to the print job or the session, not permanently change the users settings). Despite much searching on the internet I have been unable to find a means of doing this, apart from Mr Hommel's registry mods posted in this forum. I did find a number of references in C (not VBA), but they were all horribly complex (several pages of code) and also appeared to require administrator rights, which our users do not have.

My current workaround is to use a standard SaveAs dialog box to get the filename, and then use the .Printout method with the PrintToFile and PrToFileName variants. Code is below in case it is of use to anyone else - I've only included the section that does the printing.

Code Snippet

' prompt for file name to save to
fileSaveName = Application.GetSaveAsFilename(InitialFileName:="T:\PSI\PSI.mdi", _
fileFilter:="Microsoft Document Imaging Format (*.mdi), *.mdi")

' if the user cancels the SaveAs dialog, fileSaveName is False, and print is skipped
If fileSaveName <> False Then

' set active printer to minimise chance of printing to default printer
Application.ActivePrinter = "Microsoft Office Document Image Writer on Ne00:"

' print to mdi file
ActiveWindow.SelectedSheets.PrintOut Copies:=1, _
ActivePrinter:="Microsoft Office Document Image Writer on Ne00:", _
Collate:=True, PrintToFile:=True, PrToFileName:=fileSaveName

End If

Notes on the code snippet for others who may attempt to use it.

The main drawback is that apart from the Default Folder setting (which is bypassed using this method), all other MODI settings are determined by the user's Printer Preferences for the MODI printer. This includes whether a TIFF or mdi file is written (even though they choose a .mdi filename, they may still end up with a TIFF file). This is the main reason I'd prefer to use the printer driver settings and dialog instead of this workaround.

This works most of the time, but occasionally, and for no reason that I have been able to determine, the file is sent to the user's default printer instead of the MODI writer, or the resultant .mdi file is corrupt (a smaller file size, and unrecognised file type error on attempts to open it). Those occurrences are not user dependent - both have happened to me on my normal PC - and then I try again and it works fine.

Setting the Application.ActivePrinter before the .PrintOut method seems to be necessary as the ActivePrinter variant of the .PrintOut method doesn't appear to do anything. Experimentation indicates that if the two are different the Application setting takes precedence.

I'm uncertain if the "on Ne00:" portion of the printer name is necessary. Excel recorded it that way, but other examples on the net do not seem to include it. I suggest that if you want to try this, macro record the print to the MODI printer and use the printer name as recorded.

In case it matters, I'm running Office 2003 under WinXP SP2.

Thank you.




Re: Microsoft Document Image Printer - MODI Settings via VBA without using registry

JoeDee

I'm trying to print a spreadsheet in landscape, the spreadsheet is printing fine....except it's in portrait. Changing the Public_Orientation to 2 doesn't seem to make any difference.

Anyone know what values can be used with Public_PaperSize or have any idea why things are still printing in portrait

Thanks in advance