Code problems

G

GastonFranzini

Hi, I havesome trouble making this excel macro work.
What I need to do is to open a word document that is uplodaded by it´s

linked data to the excel, then I need to save it and then print it.
The trouble is that PDF asks me for the filename so the user has to
enter a name.
I tried the named argument filename:= fnamepdf but it doesn't woork.
and also Word asks me to press ok because of Normal.dot.
Thanks in advace for the help.


-----------------------------------------
Sub wordchage()


Dim WordApp As Object


Set WordApp = CreateObject("Word.Application")


fpath = ThisWorkbook.Path


doc = fpath & "\" & ("Base.doc")
Sheets("Incumbent").Select
LetterTemplate = doc
fname = Range("A3")
fnamedoc = fname & ".doc"
With WordApp


..Documents.Open LetterTemplate
..Visible = True


End With


fname = fname & ".pdf"
WordApp.ActiveDocument.PrintOut Background:= False


WordApp.ActiveDocument.SaveAs Filename:=fpath & "\" & fnamedoc


WordApp.Quit
Set WordApp = Nothing


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top