Hi,
I am trying to set up a macro so that when I run it, in loops through all the cells in a column that have a value, and creates a PDF (using the name / location from the adjacent column)
So, I have a spreadsheet that looks like this:
1 c:\temp\1.pdf
2 c:\temp\2.pdf
3 c:\temp\3.pdf
When I run the Macro, I want to create 3 PDF - 1 with "1" in it, 1 with "2" in it, and 1 with "3" in it. (this is a small piece of a much larger project).
Here's what I have compiled based on other scripts that I have that do work....unfortunately, this doesn't seem to. When I run it, I get a "Compile error: Invalid qualifier"
Sub Main()
Dim MyFile As String, DestFile As String
Dim lastrow As Long
With ActiveSheet
lastrow = .Cells(1, .Rows.Count).End(xlToDown).Row
For i = 1 To lastrow
MyFile = .Cells(i, 1).Value
DestFile = .Cells(i, 2).Value
MyFile.ExportAsFixedFormat Type:=xlTypePDF, Filename:=DestFile
Next i
End With
End Sub
I am trying to set up a macro so that when I run it, in loops through all the cells in a column that have a value, and creates a PDF (using the name / location from the adjacent column)
So, I have a spreadsheet that looks like this:
1 c:\temp\1.pdf
2 c:\temp\2.pdf
3 c:\temp\3.pdf
When I run the Macro, I want to create 3 PDF - 1 with "1" in it, 1 with "2" in it, and 1 with "3" in it. (this is a small piece of a much larger project).
Here's what I have compiled based on other scripts that I have that do work....unfortunately, this doesn't seem to. When I run it, I get a "Compile error: Invalid qualifier"
Sub Main()
Dim MyFile As String, DestFile As String
Dim lastrow As Long
With ActiveSheet
lastrow = .Cells(1, .Rows.Count).End(xlToDown).Row
For i = 1 To lastrow
MyFile = .Cells(i, 1).Value
DestFile = .Cells(i, 2).Value
MyFile.ExportAsFixedFormat Type:=xlTypePDF, Filename:=DestFile
Next i
End With
End Sub