• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Now unable to export as a pdf [ solved ]

IPBR21054

New Member
I was using Windows 7 on my pc with the following code.
Using Dropbox i have uploaded some files then on my new Windows 10 pc downloaded & installed them.
Majority working fine expect two.

This one below will not export as a pdf file.
I see a run time error 5 which is INVALID PROCEDURE CALL OR ARGUMENT
If a invoice exists in the folder i see the message box to advise me,so the path is correct as the code checked to see if one was already saved.

When it comes to saving the active sheet as a pdf it fails to do so.

Do you see an issue or please advise how i can move on and save as a word doc
I need to fix this as ive plenty to save & print

>>> use code - tags <<<
Code:
    strFileName = "C:\Users\there\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf"
    If Dir(strFileName) <> vbNullString Then
      MsgBox "INVOICE " & Range("L4").Value & " WAS NOT SAVED AS IT ALLREADY EXISTS" & vbNewLine & vbNewLine & "PLEASE CHECK FILE IN FOLDER THAT WILL NOW OPEN.", vbCritical + vbOKOnly, "INVOICE NOT SAVED MESSAGE"
      VBA.Shell "explorer.exe /select, " & "" & strFileName & "", vbNormalFocus 'DUPLICATE INVOICE FOUND
    Exit Sub
    End If
   
    strFileName = "C:\Users\there\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf"
    With ActiveSheet
       .ExportAsFixedFormat Type:=xlTypePDF, fileName:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
 
Last edited by a moderator:
If i copy the following & paste in search box then hit enter i am taken to the folder in question no problem at all.
I have evn followed the path as shown & taken there correctly.

The lines of code above also use the same path & checks to see if an invoice already exists,this also works fine so the code is doing its job correctly.
For some reason it just wont save a pdf to that folder

"C:\Users\there\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf"
 
Do you succeed to manually export the worksheet as a PDF file using the same folder and the same exact filename within L4 cell ?​
 
The item i am saving as a pdf is a selection of my screen L4:N61
Doing what you have asked will save the whole thing ?

Is that correct or are we just doing a test at present ?
 
Back
Top