+ Reply to Thread
Results 1 to 4 of 4

run time error on other machine

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    run time error on other machine

    I'm getting a run time error (see attached) for the code below. It works on my computer...but when others try to use this function they get the error. Not sure what the path and file name its referring to or why this would come up. Any help is appreciated. Thanks!


    Sub AttachPSRSheetPDF()
      Dim IsCreated As Boolean
      Dim i As Long
      Dim PdfFile As String, Title As String
      Dim OutlApp As Object
    
     
      ' Define PDF filename
      PdfFile = ActiveWorkbook.FullName
      i = InStrRev(PdfFile, "PROJECT STATUS REPORT")
      If i > 1 Then PdfFile = Left(PdfFile, i - 1)
      PdfFile = "PROJECT STATUS REPORT" & ".pdf"
     
      ' Export activesheet as PDF
        Worksheets("PROJECT STATUS").Range("B7:O65").ExportAsFixedFormat _
         Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, _
          IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    
        
        
      ' Use already open Outlook if possible
      On Error Resume Next
      Set OutlApp = GetObject(, "Outlook.Application")
      If Err Then
        Set OutlApp = CreateObject("Outlook.Application")
        IsCreated = True
      End If
      OutlApp.Visible = True
      On Error GoTo 0
     
      ' Prepare e-mail with PDF attachment
      With OutlApp.CreateItem(0)
       
        ' Prepare e-mail
        .Subject = "Contracts - SOV - Budgets"
        .To = "email@email.com" ' <-- Put email of 'copy to' recipient here
        .Body = "Hi," & vbLf & vbLf _
    
        .Attachments.Add PdfFile
       
        ' Try to send
        On Error Resume Next
        .Display
        Application.Visible = True
        If Err Then
          MsgBox "E-MAIL WAS NOT CREATED", vbExclamation
        End If
        On Error GoTo 0
       
      End With
     
      
     
    End Sub
    Attached Images Attached Images
    Last edited by adamheon; 08-24-2016 at 04:31 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: run time error on other machine

    Where in the code do you get the error?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: run time error on other machine

    scratch original idea
    change pdfFile up top instead

      PdfFile = ActiveWorkbook.Path & "\" & "PROJECT STATUS REPORT" & ".pdf"
    ps not sure what this line is meant to do normally
      If i > 1 Then PdfFile = Left(PdfFile, i - 1)
    as subsequent line you just overwrite pdffile?
    Last edited by humdingaling; 08-23-2016 at 09:47 PM. Reason: scratch original idea, change PdfFile instead
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: run time error on other machine

    perfect thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Run time error 462 the remote server machine does not exist or is unavailable
    By kenli87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2015, 04:46 AM
  2. Time Machine Jobs
    By Legend Rubber in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-26-2015, 05:46 PM
  3. Replies: 1
    Last Post: 10-24-2014, 12:32 AM
  4. Working code on my machine is returning out of range error on another machine.
    By je.suis.ketan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2012, 11:51 PM
  5. error 40351 on one machine but not other
    By DKY in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-06-2008, 01:31 PM
  6. Replies: 2
    Last Post: 03-01-2006, 12:25 AM
  7. [SOLVED] Reference & update destin. cells on 1st machine from source workbook on 2nd machine.
    By eastside877@yahoo.com in forum Excel General
    Replies: 6
    Last Post: 02-28-2006, 01:20 AM

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