none
Problem in printing tif doc with ShellExecuteEx function/ RRS feed

  • Question

  • Hi,

    We are using the below piece of code to print the tif document ,same code is working(mean tif doc is printing correctly) correctly when we test in different desktop which has office 2003, but not working in the PC which has office 2007, it just open the tif file in windows Picture and Viewer and does not print. Any help on this greatly appreciated.

    Option Explicit

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    Private Type SHELLEXECUTEINFO

        cbSize As Long

        fMask As Long

        hWnd As Long

        lpVerb As String

        lpFile As String

        lpParameters As String

        lpDirectory As String

        nShow As Long

        hInstApp As Long

        ' optional fields

        lpIDList As Long

        lpClass As String

        hkeyClass As Long

        dwHotKey As Long

        hIcon As Long

        hProcess As Long

    End Type

    Private Declare Function ShellExecuteEx Lib "shell32.dll" (ByRef s As SHELLEXECUTEINFO) As Long

    Private Const SW_HIDE = 0

    Private Const SW_MAXIMIZE = 3

    Private Const SW_MINIMIZE = 6

    Private Const SW_RESTORE = 9

    Private Const SW_SHOW = 5

    Private Const SW_SHOWDEFAULT = 10

    Private Const SW_SHOWMAXIMIZED = 3

    Private Const SW_SHOWMINIMIZED = 2

    Private Const SW_SHOWMINNOACTIVE = 7

    Private Const SW_SHOWNA = 8

    Private Const SW_SHOWNOACTIVATE = 4

    Private Const SW_SHOWNORMAL = 1

    Private Const ERROR_FILE_NOT_FOUND = 2&

    Private Const ERROR_PATH_NOT_FOUND = 3&

    Private Const ERROR_BAD_FORMAT = 11&

    Private Const SE_ERR_ACCESSDENIED = 5            '  access denied

    Private Const SE_ERR_ASSOCINCOMPLETE = 27

    Private Const SE_ERR_DDEBUSY = 30

    Private Const SE_ERR_DDEFAIL = 29

    Private Const SE_ERR_DDETIMEOUT = 28

    Private Const SE_ERR_DLLNOTFOUND = 32

    Private Const SE_ERR_NOASSOC = 31

    Private Const SE_ERR_OOM = 8                     '  out of memory

    Private Const SE_ERR_SHARE = 26

    Private Const SEE_MASK_FLAG_NO_UI = &H400

    Private Const STYLE_NORMAL = 11

     

    Private Sub Command1_Click()

     Dim shInfo As SHELLEXECUTEINFO

     Dim lReturn As Long

     

    '60 1024 C:\DOCUME~1\s65931\LOCALS~1\Temp\cis\10682374-4081.tif

     With shInfo

               

                    .cbSize = LenB(shInfo)

                     .nShow = SW_HIDE

                    .fMask = SEE_MASK_FLAG_NO_UI

                    .lpVerb = "print"

                    .lpFile = "H:\test1.tif"

                   'SW_NORMAL 'SW_HIDE

                End With

               

                lReturn = ShellExecuteEx(shInfo)

               

    End Sub

    Wednesday, December 19, 2012 5:52 AM

Answers

  • Hi Ravi

    Since you're not actually programming using Word (or Office) your question is off-topic in the Office forums on MSDN.

    As far as I know, nothing in Office should affect how other things are printed out, unless your code is using something built-into the Office application (such as MODI), that may have changed. As far as I can tell, however, this is not the case.

    If you want to discuss the issue of "printing" as related to Word or Office you need to ask elsewhere, in any case:
      http://answers.microsoft.com/en-us/office/forum/word

    I imagine, though, that printing using Windows APIs is better discussed in a forum for programming Windows for the Desktop. It's possible that something has changed in the Windows Registry related to the DDE commands related to the .tif extension that ShellExecute uses...


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, December 20, 2012 7:44 AM
    Moderator

All replies

  • Please explain how a "tif document" is related to Word and the Word APIS, the topic of this forum.

    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, December 19, 2012 7:43 PM
    Moderator
  • Apologies for not giving the background.

    Currently one of our customer application which was developed in VB has the print functionality . the same print functionality works good for all the documents including tif in the PC which has office 2003. We have upgraded office from 2003 to 2007 in few desktops and now the same print functionality works good for all the documents except TIF. Since this issue started happening after we upgrade the office to 2007 We are suspecting that this issue related specific to office 2007.

    Thanks

    Ravi


    Ravi

    Wednesday, December 19, 2012 11:59 PM
  • Hi Ravi

    Since you're not actually programming using Word (or Office) your question is off-topic in the Office forums on MSDN.

    As far as I know, nothing in Office should affect how other things are printed out, unless your code is using something built-into the Office application (such as MODI), that may have changed. As far as I can tell, however, this is not the case.

    If you want to discuss the issue of "printing" as related to Word or Office you need to ask elsewhere, in any case:
      http://answers.microsoft.com/en-us/office/forum/word

    I imagine, though, that printing using Windows APIs is better discussed in a forum for programming Windows for the Desktop. It's possible that something has changed in the Windows Registry related to the DDE commands related to the .tif extension that ShellExecute uses...


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, December 20, 2012 7:44 AM
    Moderator