• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel VBA - Saving to specific File Extensions by Cell in Different Sheet

OmegaWolf

New Member
I would like to use Excel & VBA to open a word document upon clicking a link in Excel, and save that word document based off of a cell value.


I have no issue opening a document; I'm having trouble linking the cell name to the file name on the active sheet.


Any help would be great! This is simple...I will be a ninja someday. But not this day


http://hotfile.com/dl/141254736/19a3162/1.11.2012_ExcelRequest.xlsm.html


My code:


Dim oWd As Word.Application, oWdoc As Word.Document

Dim NewFileName As String


'Workbooks("1.5.2012_ExcelRequest.xlsm").Activate

'NewFileName = wb.Sheets("Sheet1").Range("B4").Value & ".xlsm"


Set oWd = CreateObject("Word.Application")

Set oWdoc = oWd.Documents.Add


oWdoc.Sections(1).Range.Text = "I'll format this into a template"


oWdoc.SaveAs ("C:MyTest.doc")

oWdoc.Close

oWd.Quit

Set oWdoc = Nothing

Set oWd = Nothing
 
Hi, OmegaWolf!

Slightly modified your worksheet (no need of comment link and addition of a command button) and nearly not modified your VBA code.

http://www.2shared.com/file/PEqHhuGb/Excel_VBA_-_Saving_to_specific.html

Check if this works for you, just select the cell from Table1 (predefined by you) and click the button.

Regards!
 
Back
Top