David77

Board Regular
Joined
Jun 24, 2020
Messages
109
Office Version
  1. 365
Platform
  1. Windows
Hello everybody,

I am currently having a problem with one of my files. I have made an order form where people can order goods from. They download my excel sheet and click on a submit macro which sends out the excel sheet in a PDF file through email.

This works perfectly fine when I do it myself. However, once other people do it, it comes with the following error:

1597054158610.png


If you debug it, it takes you to this location in my commandbutton macro:

1597054187737.png

Where it lights up the note "Kill strPath" with yellow.

How do I solve this? Any ideas/suggestions?

Thank you so much everybody!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,
you could try first checking that the file exists in the specified path before applying the Kill statement

VBA Code:
If Not Dir(strPath, vbDirectory) = vbNullString Then Kill strPath

Also, worth having read here:How to Post Your VBA Code).

when posting code to forum

Dave
 
Upvote 0
Hi,
you could try first checking that the file exists in the specified path before applying the Kill statement

VBA Code:
If Not Dir(strPath, vbDirectory) = vbNullString Then Kill strPath

Also, worth having read here:How to Post Your VBA Code).

when posting code to forum

Dave
Hello dmt32,

You're right. I found out that this happens if the person downloads the excel file but does not save it before using the macro. Is there a way in which I can edit the macro so it works, even if you dont save the file?

Thank you!
Best regards,
David
 
Upvote 0
Post your code using code tags - plenty here to offer suggestions to update it.

Dave
 
Upvote 0
If you're getting an error on this line...

VBA Code:
Kill strPath

...I don't understand why you're not getting an error on this one...

VBA Code:
Worksheets("Order Form").ExportAsFixedFormat xlTypePDF, strPath

In any case, since the saved PDF file is only a temporary file, try saving it in your temporary folder instead. This way the path isn't dependent on the active workbook. So, for example, try replacing...

VBA Code:
strPath = ActiveWorkbook.Path & Application.PathSeparator & "Order Form.pdf"

with

VBA Code:
strPath = Environ("temp") & Application.PathSeparator & "Order Form.pdf"
 
Upvote 0

Forum statistics

Threads
1,212,932
Messages
6,110,748
Members
448,295
Latest member
Uzair Tahir Khan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top