+ Reply to Thread
Results 1 to 3 of 3

Passing between modules

Hybrid View

  1. #1
    Registered User
    Join Date
    12-18-2010
    Location
    UK
    MS-Off Ver
    2003, 2007, 2010
    Posts
    79

    Re: Passing between modules

    Hello

    Huge amount to absorb here and more than I have time for, unfortunately. I would like to help because e-mailing out of Excel and Access is something I have to do. Would it be possible for you to distil the problem down?
    David
    Access and Excel Developer | UK

  2. #2
    Forum Contributor mcinnes01's Avatar
    Join Date
    05-25-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    449

    Re: Passing between modules

    Hi,

    Thanks for your response, basically I want to pass through the string for a word document that is created and closed in one module, and then reopen the document later on in a different module. I have played a little since I first posted and I seem to be able to pass the string through as I have got it to attach that document in my email module.

    The problem I am having is that I have passed it through to my ping module but cannot reopen the file in that module this is my code for the ping module. Basically I'm looking at if the ping fails then it will open the document, then once the document is open I want it to display the print option.

    Sub ping(DocFile As String, xFile As String)
      
       Dim nRes
       Dim x
       Dim FileDoc As String
       Dim FileX As String
       Set WordApp = CreateObject("Word.Application")
          
       With CreateObject("WScript.Shell")
            nRes = .Run("%comspec% /c ping.exe -n " & 1 & " -w " & 250 _
              & " 192.168.0.5 | find ""TTL="" > nul 2>&1", 0, True)
       End With
       
       If nRes <> 0 Then
       MsgBox ("Unable to connect to the mail server." & vbNewLine & vbNewLine _
            & "Please print off the word document if you haven't already done so " & vbNewLine _
            & "and give it the Authorisor. The file can be found in a folder " & vbNewLine _
            & "called 'STAFF CHANGES BACKUP' on your desktop. Alternative email " & vbNewLine _
            & "both the excel file and word document relating to this request to " & vbNewLine _
            & "the Authorisor")
            
            WordApp.documents.Open DocFile
            
    opdoc:  If WordApp Is Nothing Then
                GoTo opdoc
            Else
             
         x = MsgBox("Would you like to print the change request?", vbQuestion + vbYesNo, "PRINT CHANGE REQUEST")
    
                If x = vbYes Then
                    WordDoc.PrintOut
                    Exit Sub
                Else
                    Exit Sub
                End If
            End If
        Else
            FileDoc = DocFile
            FileX = xFile
            Call Emailer.EMAILLIST(FileDoc, FileX)
        End If
       
    End Sub
    This is the bit where I can't seem to get the passed string to work, not sure if its my pass or if its me coding opening the doc wrong?

    WordApp.documents.Open DocFile
            
    opdoc:  If WordApp Is Nothing Then
                GoTo opdoc
            Else
             
         x = MsgBox("Would you like to print the change request?", vbQuestion + vbYesNo, "PRINT CHANGE REQUEST")
    
                If x = vbYes Then
                    WordDoc.PrintOut
                    Exit Sub
                Else
                    Exit Sub
                End If
            End If

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1