Save as pdf help

Muffins29

New Member
Joined
Jun 15, 2012
Messages
8
For n = 4 To Sheets.Count Step 1

MyFileName = Sheets(n).Range("A6").Value
MyFileNameTwo = Sheets(n).Range("A5").Value

ChDir MyFileName

'Sheets 4,5,6 etc...
Sheets(n).ExportAsFixedFormat Type:=xlTypePDF, Filename:=(MyFileNameTwo & ".pdf"), Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

'Application.Goto Sheets(1).Range("A1")

Next n
'
End Sub


The format of MyFileNameTwo isn't saving the file as a PDF and I'm stumped. It's supposed to read xxxxxx#words.pdf but instead is saving it as xxxxxx in a non pdf file. This works on another workbook I have and I don't know why it won't with this one. Any suggestions on to why it wouldn't pull the name fromt he cell correctly? And I've double checked what's in taht cell is correct way.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
To be able to reproduce this on my machine, what is the contents of A5 and A6 on the offending sheet?
 
Upvote 0
A5 is 003_000973#CashFlow
A6 is
T:\SHARED\LEDGER\GNFS\Financials\NonConsolidate\973\
A5 pulls from other cells and A6 is a vlookup. Like I said I use this macro on another workbook. I've included it below. It works fine and saves it as a pdf

For n = 4 To Sheets.Count Step 2

MyFileName = Sheets(n + 1).Range("D3").Value
MyFileNameTwo = Sheets(n + 1).Range("E1").Value
MyFileNameThree = Sheets(n + 1).Range("E2").Value

ChDir MyFileName

'Sheets 4,6,8 etc...
Sheets(n).ExportAsFixedFormat Type:=xlTypePDF, Filename:=(MyFileNameTwo & ".pdf"), Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

' Sheets 5,7,9 etc...
Sheets(n + 1).ExportAsFixedFormat Type:=xlTypePDF, Filename:=(MyFileNameThree & ".pdf"), Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False

'Application.Goto Sheets(1).Range("A1")

Next n
'
End Sub

<COLGROUP><COL style="WIDTH: 48pt" width=64><TBODY>
</TBODY>

<COLGROUP><COL style="WIDTH: 48pt" width=64><TBODY>
</TBODY>
 
Upvote 0
Did not work. It's the filename it's saving it as. it saves the 003_000973 but ignores the #CashFlow.pdf part. Works on one macro with pulling that file name exactly as it should with 003_000973#Words.pdf
That's the only looming issue
 
Upvote 0

Forum statistics

Threads
1,203,462
Messages
6,055,563
Members
444,799
Latest member
CraigCrowhurst

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top