Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am obviously doing something wrong... I am trying desperately to avoid having to activate the Microsoft Word XXXX Object Library as this may possibly be used by others in the future and you know trying to describe how to activate references can be difficult...
The error occurs in the .ExportAsFixedFormat line, and I dunno what's wrong.. I recorded a save-do-pdf event from word itself and those are the lines I was given... I'm running office 2003 on Win7 Pro also. Sub DocToPDF() Dim WordObject As Object Dim WordDoc As Object Dim ws As Worksheet Dim path As String Dim fname As String, filename2 As String, name As String, ext As String Set WordObject = CreateObject("word.application") WordObject.Visible = False Set ws = ActiveSheet path = ws.Range("a1").Value If Right(path, 1) < "\" Then path = path & "\" End If For i = 5 To ws.UsedRange.Rows.count name = ws.Range("b" & i).Value ext = Mid(name, InStr(name, "."), Len(name) - InStr(name, ".") + 1) fname = path & name filename2 = Replace(fname, ext, ".pdf") Set WordDoc = WordObject.documents.Add(fname) With WordDoc .ExportAsFixedFormat OutputFileName:=filename2, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False .Close End With Next i Set WordObject = Nothing Set WordDoc = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Test if Word is running | Excel Programming | |||
when i save xls file, debug script is running and canno't save fil | Excel Discussion (Misc queries) | |||
How to save excel spreadsheet and word doc with one save | Excel Programming | |||
running a word macro from xl | Excel Programming | |||
running a word macro from xl | Excel Programming |