UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Save File To Folder, Access 2016    
 
   
mike60smart
post Oct 10 2018, 03:56 PM
Post#1


UtterAccess VIP
Posts: 12,822
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

I am trying to save a Report in PDF format to a folder prior to attaching to an EMail using Thunderbird.

I am getting the following error:-

Attached File  error.JPG ( 15.19K )Number of downloads: 0


CODE
Dim strPDFFilenameToStore As String

strPDFFilenameToStore = "C:\Payments\" & Me.cboAuthor.Column(1) & ".pdf"
Dim strDocName As String
Dim strWhere As String
strDocName = "rptAuthorRoyalty"
strWhere = "[AuthorID]=" & Me!AuthorID
If Me.Dirty Then Me.Dirty = False ' force a save

DoCmd.OutputTo acOutputReport, "rptAuthorRoyalty", acFormatPDF, strPDFFilenameToStore, False


Also the report does not get saved?

Any help in resolving appreciated.


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
MadPiet
post Oct 10 2018, 04:12 PM
Post#2



Posts: 2,508
Joined: 27-February 09



I'd start with something really simple like...

Debug.print strPDFFilenameToStore

and see what's in the variable. Then go from there.
Go to the top of the page
 
mike60smart
post Oct 11 2018, 06:43 AM
Post#3


UtterAccess VIP
Posts: 12,822
Joined: 6-June 05
From: Dunbar,Scotland


Hi MadPiet

Great that now saves the file OK to the Payments Folder.

It does not however generate an EMail in Thunderbird??


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
johnpdmccall
post Oct 11 2018, 08:56 AM
Post#4



Posts: 1,744
Joined: 14-March 00
From: Ayrshire, Scotland


Hi, is it pi##ing down in Dunbar too?

I think you need to use send object (before or after the code that saves the file)

Something like:

CODE
DoCmd.SendObject _
    acSendReport, _
    "rptAuthorRoyalty", _
    acFormatPDF, _
    Me.EMail, _
    , _
    , _
    "YourEMailSubject", _
    "Dear" & " " & Me!CustomerName & Chr(13) & "" & Chr(10) & Chr(13) & "" & Chr(10) & "Please find the attached report" & Chr(13) & "" & Chr(10) & Chr(13) & "" & Chr(10) & "Best regards" & Chr(13) & "" & Chr(10) & Chr(13) & "" & Chr(10) & "Your Info", _
    False


I've edited it to remove any sensitive info so haven't tested it fully.

HTH

--------------------
Cheers,
John
Go to the top of the page
 
mike60smart
post Oct 11 2018, 08:59 AM
Post#5


UtterAccess VIP
Posts: 12,822
Joined: 6-June 05
From: Dunbar,Scotland


Hi John

No In fact it is quite pleasant at the mo in Sunny Dunny

Will give this a go and get back to you

Cheers


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
mike60smart
post Oct 11 2018, 09:04 AM
Post#6


UtterAccess VIP
Posts: 12,822
Joined: 6-June 05
From: Dunbar,Scotland


Hi John

I have the following Function which contains all of the EMail info as shown below:-

CODE
Public Sub EmailViaThunderbird(pdfName As String, EMailTo As String)
Dim strShellcommand As String
Dim strThunderbirdCommand As String
Dim strTo As String
Dim strSubject As String
Dim strBodyText As String
Dim strAttachment As String
strThunderbirdCommand = "C:\Program Files\Mozilla Thunderbird\thunderbird -compose"
strTo = EMailTo
strSubject = "Payment No. " & Me.PaymentNr & " Attached from Wordwooze Publishing"
strBodyText = "Please email to confirm receipt, thank you"
strAttachment = pdfName
strShellcommand = strThunderbirdCommand & " to='" & strTo & "',cc='" & strCC & "',subject='" & strSubject & "',body=' " & strBodyText & "',attachment='file:///" & strAttachment & "'"
Debug.Print strShellcommand
Call Shell(strShellcommand, vbNormalFocus)
End Sub


Would this have to be modified in any way?

How would I call this from my On Click Event??


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
mike60smart
post Oct 11 2018, 09:35 AM
Post#7


UtterAccess VIP
Posts: 12,822
Joined: 6-June 05
From: Dunbar,Scotland


Hi John

I tried the following code:-

CODE
Private Sub cmdPDF_Click()

Dim strPDFFilenameToStore As String

strPDFFilenameToStore = "C:\Payments\" & Me.Author & ".pdf"

Dim strDocName As String
Dim strWhere As String
strDocName = "rptAuthorRoyalty"
strWhere = "[AuthorID]=" & Me!AuthorID
If Me.Dirty Then Me.Dirty = False ' force a save
DoCmd.OpenReport "rptAuthorRoyalty", acViewPreview, , "[AuthorID]=" & Me.AuthorID
Debug.Print strPDFFilenameToStore
DoCmd.SendObject _
    acSendReport, _
    "rptAuthorRoyalty", _
    acFormatPDF, _
    Me.EMailTo, _
    , _
    , _
    "Payment Report Attached", _
    "Dear" & " " & Me!Author & Chr(13) & "" & Chr(10) & Chr(13) & "" & Chr(10) & "Please find the attached report" & Chr(13) & "" & Chr(10) & Chr(13) & "" & Chr(10) & "Best regards" & Chr(13) & "" & Chr(10) & Chr(13) & "" & Chr(10) & "Your Info", _
    False
DoCmd.OutputTo acOutputReport, "rptAuthorRoyalty", acFormatPDF, strPDFFilenameToStore, False

End Sub


And I get the following error:-

Attached File  error.JPG ( 18.93K )Number of downloads: 0


Hit Debug and it highlights your Code:-

Attached File  Highlights.JPG ( 33.68K )Number of downloads: 1

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
mike60smart
post Oct 11 2018, 03:33 PM
Post#8


UtterAccess VIP
Posts: 12,822
Joined: 6-June 05
From: Dunbar,Scotland


Hi John

I removed this line of Code and it now works a treat:-

DoCmd.OutputTo acOutputReport, "rptAuthorRoyalty", acFormatPDF, strPDFFilenameToStore, False

Many thanks for the help
cheers.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    23rd October 2018 - 11:50 PM