Forum

OUTLOOK CONVERT JPE...
 
Notifications
Clear all

OUTLOOK CONVERT JPEG TO PDF

5 Posts
2 Users
0 Reactions
197 Views
(@josros60)
Posts: 47
Trusted Member
Topic starter
 

Hi,

I found this code in internet I pasted in Outlook module but when run give error 424 and 438 how can I please get help to get it to work I get lost jpeg attachments that I need to convert to PDF, much appreciated your help.

here is the code:

 

Sub JPG_PDF()
'
' JPG_PDF Macro
'
Application.ScreenUpdating = False

'Declare variables
Dim file
Dim path As String

path = "C:DocumentsFile Conversion Test"
file = Dir(path & "*.jpg")

Sheet1.Activate

'Start loop
Do While file <> ""

'Insert picture into Excel
Sheet1.Pictures.Insert (path & file)
ActiveSheet.Pictures(ActiveSheet.Pictures.Count).name = "A Picture"

ChDir "C:DocumentsFile Conversion Test"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=file, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False

ActiveSheet.Shapes.Range(Array("A Picture")).delete

file = Dir()

Loop

Sheet2.Activate

Application.ScreenUpdating = True

End Sub

 
 
Posted : 01/02/2022 4:40 pm
(@josros60)
Posts: 47
Trusted Member
Topic starter
 

Any help please.

 

Should I this code to outlook or excel file?

 

thank you

 
Posted : 02/02/2022 3:33 pm
(@catalinb)
Posts: 1937
Member Admin
 

Hi Jose,

It's an excel code, not outlook.

Make sure that you have in your excel file the sheets mentioned in code: Sheet1, Sheet2 (these are code names, not sheet names, take them from vba project)

 
Posted : 02/02/2022 3:52 pm
(@josros60)
Posts: 47
Trusted Member
Topic starter
 

Thank you Catalin.

 

I removed those sheets when I run the macro nothing happens.

 
Posted : 02/02/2022 5:46 pm
(@catalinb)
Posts: 1937
Member Admin
 

Why would you remove those sheets? I mentioned to make sure you HAVE those sheets in your workbook, or update the code to your sheet code names.

Is the folder path correct?

path = "C:DocumentsFile Conversion Test"

Do you have "*.jpg" files in there? (if you have .jpeg, make sure you update the code, these details should be obvious)

 
Posted : 03/02/2022 1:12 am
Share: