Word to PDF

Prince27

New Member
Joined
Nov 24, 2012
Messages
41
Hi,

I am looking for a macro for the below criteria :

1. There are multiples pages in a word document
2. If i run a macro the word document should get convert into pdf.
3. Only the current page should get convert into pdf
4. It should take me to the Desktop or which ever path i give in the vb code.
5. It should allow me to give the name of the file

Can someone help me with the VB Code....
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Why do you need a macro for what can be done via File|Save As>Save As type: PDF>Options?
 
Upvote 0
In our day to day work we convert 10000 word documents to pdf manually.

With the help of macro at least we can save some time
 
Upvote 0
I've been away for 3 1/2 months, hence the delay in replying.

Somehow I doubt you're manually converting all or part of a document to PDF every 20 seconds or so ... especially if you need to supply file paths and the like! That said, you should be able to use code like:
Code:
Sub SavePage()
Dim StrPath As String, StrName As String
StrPath = GetFolder & "\"
If StrPath = "\" Then Exit Sub
StrName = InputBox("Input the Filename")
If StrName = "\" Then Exit Sub
If Right(UCase(StrName), 4) <> ".PDF" Then StrName = StrName & ".PDF"
MsgBox StrPath & StrName
With ActiveDocument.ExportAsFixedFormat
  .OutputFileName = StrPath & StrName
  .ExportFormat = wdExportFormatPDF
  .OpenAfterExport = False
  .OptimizeFor = wdExportOptimizeForPrint
  .Range = wdExportCurrentPage
  .Item = wdExportDocumentContent
End With
End Sub

Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,693
Members
449,117
Latest member
Aaagu

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