View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mia Mia is offline
external usenet poster
 
Posts: 101
Default Looping and saving pdf

I hope someone can help me with this. I am trying to save pdf-files
togetherwith looping. The reason is that only specified documents should be
saved. I´ll be grateful for your help. My code so far is as follows.

BR
Mia



Sub bevispdfttest()
'
' Spara som pdf i mapp Makro
'

Dim FilenameStr As String
Dim Start As Integer
Dim Stopp As Integer
Dim SkrivUt As String

Sheets("Kunddata").Select
Start = Range("C11").Value
Stopp = Range("C12").Value


For i = Start To Stopp
Sheets("Kunddata").Select
Range("C14").Value = i
SkrivUt = Range("F15").Value
If SkrivUt = "S" Then

Sheets("Faktura").Select


If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") < "" Then

FilenameStr = "P:\Testmapp\" & _
ActiveSheet.Range("G6").Value & " " & Format(Now, "yyyy-mm-dd") &
".pdf"

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

End If
Next
Sheets("Kunddata").Select
End If
End Sub