Windows 10 "temp" folder access with VBA

danielp38

New Member
Joined
Feb 10, 2017
Messages
2
Hello all,

Is there someone who have a solution to my problem ?

I have an Excel workbook with an automatic fonction that copy part of a workbook in jpg then sent it using outlook. It used to work fine with Windows 7 and Windows 8 using Office 2013. Now, we are moving to Windows 10 and to Office 2016. I'm getting an error "Execution Error -2147024894 (800070002) File not found"

The code is :
Set Message = Appoutlook.CreateItem(olMailItem)

With Message
TempFilePath = Environ$("temp") & ""
.Attachments.Add TempFilePath & "DashboardFile.jpg", olByValue, 0
...
.HTMLBody = " .... "
.SentOnBehalfOfName = SenderName
.Display
End With

I have try running Excel as administrator and it's working. I have also tried another folder (eg. c:\temp) but got the same result.

But I cannot allow this for the user.

Beside unabling the UAC
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Welcome to the forum! When pasting code, please do so between code tags. Click # on the toolbar to insert the tags.

Obviously, the file does not exist. The error likely occurred earlier where the file was created? %temp% path is specific to your login profile. Others would not be able to access it. You can see the path in VBE's Immediate window after a run by using:
Code:
Debug.Path TempFilePath & "DashboardFile.jpg"
 
Upvote 0
Thanks a lot,

I was getting blind, someone has edited previous line : Call CreateCharObjectAsJPEG("DashboardFi1e"). As the code use to work fine, I didn't expected that
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,775
Members
452,353
Latest member
strainu

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