VBA Fax using fax server on server from computer on network - vba

I am running Windows Server 2008 R2. I installed the fax server role on the server. I am able to fax documents using the external fax modem attached to the server from computers attached to the network by printing the documents and selecting "Fax on MYSERVER". I am able to fax a .pdf using the following code (which I got from mdsn.microsoft.com) from the server but not from any other computer even when logged into the computer using the administrator account.
Sub fax_report(location_fax_number, report_name, fax_location, fax_file_path)
Dim objFaxDocument As New FAXCOMEXLib.FaxDocument
Dim objFaxServer As New FAXCOMEXLib.FaxServer
Dim JobID As Object
On Error GoTo Err_Clear
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
'Connect to the fax server
objFaxServer.Connect ("\\MYSERVER")
'Set the fax body
objFaxDocument.Body = fax_file_path
'Name the document
objFaxDocument.DocumentName = report_name
objFaxDocument.Recipients.add (location_fax_number)
JobID = objFaxDocument.ConnectedSubmit(objFaxServer)
objFaxServer.Disconnect
End Sub
The error I'm getting is:
Description: "Operation failed"
HelpContext: 1000440
HelpFile: "C:\Program Files (x86)\Common Files\Microsoft
Shared\VBA\VBA7.1\1033\VbLR6.chm"
LastDllError: 0
Number: -2147023741
Source: "FaxComEx.FaxDocument.1"
Although I am able to fax a .pdf from the server when I try from a computer on the network it fails. I am able to send a .txt file fro a computer on the network. It looks like the .pdf isn't automatically being converted to a .tiff file like it is when I run the code on the server. When I run the code from the server Adobe Acrobat Reader DC opens, the .pdf is opened and converted then faxed without error. Adobe stays open and I can see a temp file was created, it isn't available to be opened from the recent file lists menu.

I figured out the solution. I needed to set Adobe Acrobat Reader DC as the default program to handle .pdfs on the remote computers.

Related

LotusScript - Issue with MS word processing on HCL Domino 11 server

I am trying to create Word object and open existing word file in web based Domino application. I am able to create the word application and open document when I run the same script in Notes client on Domino server. However I am receiving "Type mismatch" error when I run it through web agent on server.
Version - MS word for MS office 365
HCL Domino server version 11
Following is the Lotusscript code present in the Agent. Agent has "Allow restricted operations with full administrative rights" selected.
Dim offApp as variant
Dim offDoc as variant
Set offApp = CreateObject("Word.Application") --- Word object is created successfully.
Set offDoc = offApp.documents.Open(tempDir & "Test.docx") ---- Error - Type mismatch

Error Printing: No application is associated with the specified file for this operation

I have a VB WinForms app that prints PDFs using Process.Start, and it has been working fine for ages on Windows 10. Today I go to use it and get the following error message:
"No application is associated with the specified file for this operation"
Nothing has changed to cause this, I have not changed PDF Viewer or uninstalled anything. I can open a PDF by double clicking on it no problems.
I wrote a small console app to replicate the issue and prove this had nothing to do with the WinForms app:
Sub Main()
Dim pi As New Diagnostics.ProcessStartInfo
Dim url As String = "C:\PathToPDF\.pdf"
pi.FileName = url
pi.Verb = "PrintTo"
pi.CreateNoWindow = True
pi.Arguments = """Microsoft Print to PDF"""
pi.UseShellExecute = True
Console.WriteLine(url)
Diagnostics.Process.Start(pi)
Console.ReadKey()
End Sub
The above program replicates the error. I have verified that the file exists and is accessible and tried it with double slashes and single slashes, they give the same error:
"No application is associated with the specified file for this operation".
The same application is working fine on other PCs in the office.
Has anyone else had this happen, and if so how did they fix it?
My PDF viewer is PDFXChange Viewer, and it has been working fine PDFs printed using this method for years. I have not updated the program, and it says in the about page that the last installed updated was in 2016.
Regards.
If I am right, I had the same issue. Maybe you can try it in a slightly other way. I have this in my application and it works fine:
Dim myp As New Process
myp.StartInfo.FileName = filename 'Full path to pdf
myp.Start()

getting error while opening excel workbook in scheduled agent

I got a problem in scheduled agent in lotus script while opening csv workbook.It simply opens workbook from Excel and reads the data.
It works perfectly fine when I run manually. It throws when schedule at workbooks.open line.
Agents Settings : Allow resticted operations with full admin rights.
Code :
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlApp.DisplayAlerts = False
Print "New filepath=" & filepath
xlApp.Workbooks.Open filepath ' Open the CSV file
Set xlWorkbook = xlApp.ActiveWorkbook
Set xlSheet = xlWorkbook.ActiveSheet
filepath=C:\Temp\transit_15102008.csv
Error thrown at log.nsf
printing: ERROR : Transfer Files agent- Microsoft Office Excel: Microsoft Office Excel cannot access the file 'C:\Temp\transit_15102008.csv'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook. at line-55
There is only one worksheet in the Excel.
I am not able to figure out the issue. Please somebody help me to resolve. Thanks in advance.
When you run your agent manually, it runs in your workstation context where (I assume) there is MS Office installed.
But when your agent runs as scheduled, it runs in the server context, and if you don't have MS Office installed on the server, or there's no file on the path: C:\Temp\transit_15102008.csv on the server, then your agent fails.
Solution:
Make sure you have MS Office properly installed on the server where your scheduled agent runs.
Make sure that there is file present on the path C:\Temp\transit_15102008.csv on your server where your scheduled agent runs.

Invalid Mail Attachment

I have a windows service that sends out emails by retriving the records from the database. The service account Windows Service is running under, is a Local admin on that machine. The issue i am having is somehow the windows service manages to send out some emails with pdf attachements that exist on the local server where windows service is located and for most of them i get an error message: Invalid Mail Attachment and having real difficulties what could be causing it? any idea on where should i start looking please?
Thanks
Try
' Initialize new mail message class
Dim objEmailMessage As New System.Net.Mail.MailMessage(EmailOutboxEntity.EmailFrom, EmailOutboxEntity.EmailTo)
' Set the email parameters
objEmailMessage.Subject = EmailOutboxEntity.EmailSubject
objEmailMessage.Body = EmailOutboxEntity.EmailBody
' Check if attachments have been specified
If Not EmailOutboxEntity.TestOriginalFieldValueForNull(EmailOutboxFieldIndex.EmailAttachements) Then
' Get an array of attachment file names to send
Dim arrAttachment As String() = Split(EmailOutboxEntity.EmailAttachements, CONST_AttachmentSeparator)
' Step through each filename and attach it to the email
For Each strAttachment As String In arrAttachment
' Attach the current file to the email
objEmailMessage.Attachments.Add(New System.Net.Mail.Attachment(strAttachment))
Next
End If
' Set the SMTP server
Dim mailServer As New System.Net.Mail.SmtpClient(pstrSMTPServer)
' Send the message
mailServer.Send(objEmailMessage)
Catch errException As Exception
' Throw an exception indicating the email failed to send
Throw New EmailOutboxManagerException(errException.Message, "Test Failed to send email, got the following error instead:")
End Try
Sorry Guys, as i have figured out the answer and it was my fault because i was running two different versions of the windows service on different servers and they were both picking up the attachments from the database and the path existed on one server where the files were saved and not on the other server and that's why some of the emails were managed to be sent.

No application is associated with the specified file for this operation (VB.NET)

We have a Win Forms application that produces a pdf with iTextSharp, saves it to a local directory and the application then opens the file. With one customer (all XP boxes and Adobe Reader 11) it throws the following error
No application is associated with the specified file for this operation
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
Which would suggest Adobe Reader is not associated correctly with the pdf extension apart from the fact they can navigate to the local directory and open the file without any problem whatsoever.
Anyone come across this oddity before?
Edit re ZippyV - example of a typical sub
Public Sub PDF_Functions_LogCalls_RunReport(ByVal Customer As Boolean)
Try
Dim vOutput As String = LogCalls_Run(Customer)
If Left(vOutput, 5) = "Error" Then
TaskDialog.Show(MainForm, AppBoxError("File Error", vOutput, "Error"))
Exit Sub
End If
If System.IO.File.Exists(vOutput) Then
Dim P As New Process
P.StartInfo.FileName = vOutput
P.StartInfo.Verb = "Open"
P.Start()
End If
Catch ex As Exception
EmailError(ex)
Exit Sub
End Try
End Sub
You're reading the error message wrong. I've added emphasis to the relevant part:
No application is associated with the specified file for this operation
This means that there is no application associated with the verb "Open". Change your code to simply use an empty string (or just don't set) the Verb:
P.StartInfo.FileName = vOutput
P.StartInfo.Verb = ""
P.Start()
This uses whatever the default operation is for the .pdf format, which will match the operation the user would get if they double-clicked the file in Windows Explorer.
Recent versions of Acrobat are setting the default action to "Open with Adobe Reader XI" instead of just "Open", as you can see if you right-click a .pdf file.
This is seemingly what's causing the "not associated for this operation" error.
This error actually happens when there is a difference between the default behaviour of opening the file and the relative behaviour of opening the file.
For example, if you have selected the default application to open .pdf files as Internet Explorer, and you are trying to open the same file using Process.Start() method. You will receive an exception because as per the default operations it should open that file in Internet Explorer and your application is trying to open it using Adobe reader.
To rectify this set the default application for the .pdf file as Adobe Reader and you won't receive this error any more.