Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-30-2017, 01:05 PM
babysatch babysatch is offline Creating a word file and then making a pdf from excel Windows 10 Creating a word file and then making a pdf from excel Office 2016
Novice
Creating a word file and then making a pdf from excel
 
Join Date: Apr 2017
Posts: 6
babysatch is on a distinguished road
Default Creating a word file and then making a pdf from excel

Hi,

does anybody have any idea what am I missing in the code below:

I get this error:

Run time '5':


Invalid Procedure call or invalid argument

Here is the code:

Code:
Private Sub CommandButton1_Click()
    Dim MSWord As Object                            
    Set MSWord = CreateObject("Word.Application")   
    MSWord.Visible = True                          

    Datei = "D:\WordTest.doc"                   
    pdfName = "D:\WordTest.pdf"
                                                    
    MSWord.Documents.Add                           
    With MSWord.Selection
        .Font.Name = "Helvetica"                        
        .Font.Size = 20                           
        .Font.Color = wdColorRed                  
        .Font.Bold = True                       
        .Font.Italic = True                     
        .TypeText Text:="Text"                  
        .TypeParagraph                             
    End With

    MSWord.ActiveDocument.SaveAs Datei            
    

       MSWord.ActiveDocument.ExportAsFixedFormat OutputFileName:=pdfName, _
        ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, Item:= _
        wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
    

    
    
    MSWord.ActiveDocument.Close                   

    MSWord.Quit                                     
    Set MSWord = Nothing                            






End Sub

Ist it possible to open a pdf-file created by ActiveDocument.SaveAs2-Method?


Thank you.

Last edited by macropod; 04-30-2017 at 04:18 PM. Reason: Added code tags
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a word file and then making a pdf from excel Excel does not work if any other excel file selected in any folder tonytonytony Excel 3 03-10-2016 04:18 PM
Creating a word file and then making a pdf from excel Making Venn Diagram in Excel kareemva Excel Programming 5 02-16-2016 12:10 AM
Creating a word file and then making a pdf from excel How to update source excel file with changes made to insserted excel file in OneNote winwell OneNote 1 11-03-2015 12:19 PM
sending data from UserForm of existing excel file to a new excel file saltlakebuffalo Excel Programming 0 02-13-2014 10:55 PM
Creating a word file and then making a pdf from excel how to copy some information from one excel file to another excel file tomlam Excel Programming 4 10-01-2013 03:06 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:51 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft