Design by Sue
Registered User.
- Local time
- Today, 00:25
- Joined
- Jul 16, 2010
- Messages
- 816
I don't know what to do --- that is as always my problem. I just know that the code works to save it to the correct folder but will not cancel when cancel is clicked. I do not understand at all how it is working because there is nothing showing in the Excel sub that displays the folder name.Ok, and what are you going to do with that?
Why not show what it is when you get back to the Excel sub?
Excellent help - I am leaving for the day so will be back to this on Wednesday. Will research how to do this, nice to know what I need to look up. Have a great evening and thanks for hanging in there with me.The path coming back from the function does not have a trailing backslash, so you need to add that.
You then need to concatenate that with your report name in a similar manner as you do with the date, but obviously goes before the report name.
If unsure, set it all up in a string variable that you can debug.print to see what you have and then just use that in the OutputTo command.
Thanks will look at this when I get back - I copied the code from a website so it is the way it came to me. Appreciate the comment!I will add a side comment. You have a FOR loop screen-shot in post #21 and it looks at a property of selected items. However, you should be aware that it starts from 1 to the .Count and the problem is that Access collections (such as but not limited to .SelectedItems) start counting from 0, i.e. zero-based numbering. If you start from .SelectedItems(1), you have SKIPPED the item you wanted to catch, which is .SelectedItems(0).
That was not the case when I tested it Doc?I will add a side comment. You have a FOR loop screen-shot in post #21 and it looks at a property of selected items. However, you should be aware that it starts from 1 to the .Count and the problem is that Access collections (such as but not limited to .SelectedItems) start counting from 0, i.e. zero-based numbering. If you start from .SelectedItems(1), you have SKIPPED the item you wanted to catch, which is .SelectedItems(0).
Sorry - I think I found the solutionFound a little time to poke a this.
The
Dim strPath As String
Dim strGoToPath As String
strPath = GetFolderName()
Debug.Print strPath
strGoToPath = "strPath\SOP30DayRPT - " & Format(Date, "mmddyyyy") & ".xls"
Debug.Print strGoToPath
strPath in the debug does show the correct path but I am not clear how to get the correct code for strGoToPath
the results are
(strPath)\SOP30DayRPT - 08262024.xls
Can you help me with how to refer to strPath in the strGoToPath? Not sure how to format this. I have tried all kinds of combinations but can't find the solution and can't find the answer onlne.
thanks
I would not even try to assemble strGoToPath until I know strPath has a value.Sorry - I think I found the solution
Here is the final excel sub as I have it now and it seems to be working
Private Sub ExportExcel_Click()
Dim strPath As String
Dim strGoToPath As String
strPath = GetFolderName()
'Debug.Print strPath
strGoToPath = strPath & "\" & "SOP30DayRPT - " & Format(Date, "mmddyyyy") & ".xls"
'Debug.Print strGoToPath
If strPath = "" Then
Exit Sub
Else
DoCmd.OutputTo acOutputReport, "SOP30DayRPT", acFormatXLS, strGoToPath
End If
Once again thanks for your help. If you see anything wrong please if you could let me know I would appreciate it.
Module as Public.I know that there is a way to put the GetFolderFuncton somewhere so that it is available and can be referenced on all reports so it does not have to be included on each report but I can't remember where to put it. Module? Macro?