2 Replies Latest reply: Mar 21, 2016 12:52 PM by Neil Woodham RSS

    Passing control between Qlikview and word

    Neil Woodham

      Hi,

       

      I am having trouble using VB script change sheets then open word and start printing to it.

       

      If I start the script when I am on the QV sheet there is no problem, but if I start on a different QV sheet then the QV macro wont copy.

       

      I think it is a problem on how I use 'set activedocument' , but I cant be sure.

       

      my process is first to set Qlikview as the application and the activate the sheet

       

       

      set QD = ActiveDocument.GetApplication
      QD.ActiveDocument.ActivateSheetByID "SH09"

      Then open word and set the .Activedocument

       

      Set objFSO = CreateObject( "Scripting.FileSystemObject" )
      Set objWord = CreateObject( "Word.Application")

       

      Set objDoc = .ActiveDocument

       

      Then use the first set command to activate the sheet again

       

      QD.ActiveDocument.ActivateSheetByID "SH09"
      ActiveDocument.GetApplication.WaitForIdle

      set objSource2=ActiveDocument.GetSheetObject("CH40")

       

      The problem is if I dont start on Sheet SH09 the macro wont copy.

       

      Where am I going wrong?

        • Re: Passing control between Qlikview and word
          m w

          Set objDoc = objWord .ActiveDocument

          • Re: Passing control between Qlikview and word
            Neil Woodham

            My code to open and set word is below, I think my problem is changing sheets in Qlikview, somehow when qlik is not active (because it is .activedocument in word) it won't GetSheetObject to copy from in Qlik

             

             

              With objWord
            ' True: make Word visible; False: invisible
            .Visible = True

            ' Check if the Word document exists
            If objFSO.FileExists( myFile ) Then 
            Set objFile = objFSO.GetFile( myFile )
            strFile = objFile.Path
            Else
            msgbox "FILE OPEN ERROR: The file does not exist" & vbCrLf
            ' Close Word
            .Quit
            Exit Sub
            End If
            ' Open the Word document
            .Documents.Open strFile

            ' Make the opened file the active document
            Set objDoc = .ActiveDocument
            end with