Help with VBA

Hi All,

I'm a newbie to programming and need help with a fairly simple VBA project for work. Starting in MS Excel, I'm trying to program a Macro to (1) open an existing file in MS Word, (2) enter some text from MS Excel into MS Word, and (3) Save the MS Word document with a dynamically generated file name.

For some reason, I can not get the MS Word document to save to a new file name. Would appreciate your help in figuring out what's wrong with this code!!

(Note: the variables dt and docName are created in an earlier part of the code and I'm confident they're working correctly. I'm just limiting the below code sample to the messed up code)

Dim wrdApp As Word.Application
Set wrdApp = CreateObject("Word.Application")
Dim wrdDoc As Word.Document
Set wrdDoc = wrdApp.Documents.Open("C:\Desktop\Quote_Template.doc")

With wrdApp
    .Selection.Goto What:=wdGoToBookmark, Name:="Date"
    .Selection.TypeText (dt)
End With

wrdDoc.SaveAs ("C:\Desktop\" & docName)

End Sub
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Does docName include the extension?
DC1983Author Commented:
Macro, thank you for your response. Yes, the docName has a ".doc" at the end of the variable.
Did you get an error message ?

did you do a display of "C:\Desktop\" & docName immediate before the saveas ?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DC1983Author Commented:
Wow! Just tried it and the error was in that piece of code. Thanks so much for the help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.