LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Saving a Word document as PDF from en Excel macro

Hello NG

I have an Excel macro, that creates a number single Word-documents (not mail merge), based on data from en Excel spreadsheet, using bookmarks in the Word document. I want to save the documents as PDF files, but so far with no success.

My code startes with:

On Error Resume Next
Set Wdapp = GetObject(, "Word.Application")
If Err.Number < 0 Then
Set Wdapp = CreateObject("Word.Application")
End If

<followed by a lot of of transfer from Excel to Word stuff and then I try to save as PDF with:

doknavn = ldir & "\" & a & ".pdf"
Wdapp.ChangeFileOpenDirectory ldir
Wdapp.ActiveDocument.ExportAsFixedFormat OutputFileName:= _
doknavn, ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportAllDocument, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=False

but nothing happens. Apparently no pdf files are created. If i save as Word documents in stead, like in this test

Wdapp.ActiveDocument.SaveAs Filename:="C:\test\" & Navn & number & ".doc"

it Works perfectly. If I run the same code in a Word-document, it works as well. Can't you automate exports to pdf?

Anyone?

Jan

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro For Saving Worksheet to Word Document with A1 as filename ghillman89 Excel Programming 0 March 5th 12 02:58 AM
Macro to open a word document from excel MarkC Excel Programming 11 April 3rd 07 09:34 AM
Printing a Word document from an excel macro Mike_Shimandle Excel Programming 1 September 30th 04 04:13 PM
Printing a Word document from an excel macro mshimandle Excel Programming 0 September 30th 04 04:07 PM
using excel macro to activate word document Amy[_4_] Excel Programming 1 August 12th 03 12:40 AM


All times are GMT +1. The time now is 08:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"