Share via

what is wrong in this code

Anonymous
2023-08-14T12:42:34+00:00

Sub SaveAsPdf()

Dim invno As Long

Dim custname As String

Dim amt As Currency

Dim dt_issue As Date

Dim payment As String

Dim path As String

Dim Fname As String

Dim nextrec As Range

invno = Range("C3")

custname = Range("B10")

amt = Range("H39")

dt_issue = Range("C4")

payment = Range("C6")

path = "C:\TechZone\Invoices"

Fname = invno & " - " & custname

With ActiveSheet

 .ExportAsFixedFormat Type:=xlTypePDF, Filename:=path & Fname, Quality:=xlQualityStandard, includedocproperties:=True, ignoreprintareas:=False, openafterpublish:=False 

Set nextrec = Sheet3.Range("A1048576").End(xlUp).Offset(1, 0)

nextrec = invno

nextrec.Offset(0, 1) = custname

nextrec.Offset(0, 2) = amt

nextrec.Offset(0, 3) = dt_issue

nextrec.Offset(0, 4) = payment

Sheet3.Hyperlinks.Add anchor:=nextrec.Offset(0, 5), Address:=path & Fname & ".pdf"

End With

End Sub

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. HansV 462.6K Reputation points
    2023-08-14T13:10:26+00:00

    What is the problem?

    • Do you get an error message when you run the macro? If so:
      • What does the error message say?
      • Which line is highlighted when you click Debug in the error message?
    • Or is the result not what you wanted/expected? If so, in what way?
    • Or something else?

    Was this answer helpful?

    0 comments No comments