Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 7th, 2004, 06:24 PM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default MODI Automation

I am trying to work with .mdi files (Microsoft Office Document Imaging/MODI) from within Excel but am getting stuck. I can create the initial .mdi file:

  Dim Viewer As New modi.MiDocView
  Dim myDoc As New modi.Document
  Dim this_sheet As Worksheet
  Application.Worksheets("Sheet 1").Activate
  Application.ActivePrinter = _
     "Microsoft Office Document Image Writer on Ne00:"
  Set this_sheet = Application.ActiveSheet
  this_sheet.PrintOut _
     printtofile:=True, prtofilename:="test.mdi"

Viola, I get my test.mdi file up on the screen. For the life of me, though, I cannot do anything with the document (printout or save) via the MODI Viewer. I have tried countless variations of the following, but w/ no luck:

   Viewer.Document = myDoc

I've used "Set" and "New" and flipped things around, but without luck. Ultimately I want to do something as simple as:

   myDoc.PrintOut
   myDoc.SaveAs "my_file.mdi"
   myDoc.Close

Help!

ArtDecade
__________________
ArtDecade
 
Old November 7th, 2006, 06:54 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This worked for me... I want to convert DOC files to TIFF.

        Dim AppWord As Word.Application = New Word.Application
        Dim objCurrentDoc As Word.Document = New Word.Document
        objCurrentDoc = AppWord.Documents.Add("C:\test2.doc")
        AppWord.ActivePrinter = "Microsoft Office Document Image Writer"
        objCurrentDoc.PrintOut(PrintToFile:=True, OutputFileName:="c:\test2.tif")
        objCurrentDoc.Close()
        AppWord.Quit()

Ensure to add COM references to MODI and Word in your project. The above was used in VB.NET 2005.
 
Old February 15th, 2007, 04:41 AM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Joe,

The code you have mentioned works perfectly. I have a couple of doubts to ask you.
1.What should i do if i have to print/convert only a few pages. eg. only page 1 or say a range from 2-4?.
2. How can i find out the total numbers of pages in the opened word document?

Please help me on this.

Thanks and Regards
Vipin

 
Old March 5th, 2009, 02:04 AM
Registered User
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Urgent :Converting Excel to tiff using MODI

hi friends,

I want o convert the Excel document into tiff using the MODI . I had tried the following code but it

Dim AppExcel AsNew Microsoft.Office.Interop.Excel.Application
Dim objCurrentDoc AsNew Microsoft.Office.Interop.Excel.Workbook

objCurrentDoc = AppExcel.Documents.Add(
"C:\workings.xls")
AppExcel.ActivePrinter =
"Microsoft Office Document Image Writer"
objCurrentDoc.PrintOutEx(PrintToFile:="c:\workings.tif")
objCurrentDoc.Close()
AppExcel.Quit()

throws an error in second line

System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2147221164
Message="Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154."
Source="DocumentConvertor"
StackTrace:
at DocumentConvertor.Form1.ConvertExcelToTiff() in C:\Vb.net\DocumentConvertor\DocumentConvertor\Form 1.vb:line 35 at DocumentConvertor.Form1.Form1_Load(Object sender, EventArgs e) in C:\Vb.net\DocumentConvertor\DocumentConvertor\Form 1.vb:line 17 at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m) at System.Windows.Forms.ContainerControl.WndProc(Mess age& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolea n value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationCo ntext context) at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[] commandLine) at DocumentConvertor.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context( Object state) at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
InnerException:


Any ideas mate...pls share

Thanks
vijay





Similar Threads
Thread Thread Starter Forum Replies Last Post
IE automation kg8299 Excel VBA 3 June 8th, 2010 02:43 PM
Prevent MODI from opening after PrintOut dcase Word VBA 1 March 3rd, 2007 06:28 AM
automation ASCIIMAN Pro VB 6 1 January 29th, 2007 02:25 PM
automation! Khalifeh VB How-To 6 October 26th, 2006 12:45 PM
MODI.Document.SaveAs Method hannah_h VB.NET 2002/2003 Basics 5 January 13th, 2005 09:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.