+ Reply to Thread
Results 1 to 4 of 4

How to automatically add the Value of a spesific Cell into the "Save" filename?

  1. #1
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    How to automatically add the Value of a spesific Cell into the "Save" filename?

    Hello guys,

    How do I automatically add the Value of a specific Cell (Range("H8".Value) into the "Save" name when running the following Macro:

    Please Login or Register  to view this content.

    If I do the following then it also automatically ads .xlms between the FileName and the Range("H8").Value......
    Please Login or Register  to view this content.
    Last edited by tnuis; 09-09-2013 at 03:30 PM.

  2. #2
    Registered User
    Join Date
    05-18-2013
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to automatically add the Value of a spesific Cell into the "Save" filename?

    you can Try adding the following:

    Sub ExcelToPDF2()

    Dim iPtr As Long
    Dim sFileName As String

    If iPtr = 0 Then
    sFileName = ActiveWorkbook.FullName & ".pdf"
    Else
    sFileName = Left(ActiveWorkbook.FullName, iPtr - 1) & ".pdf"
    End If

    sFileName = Range("h8").Value + ".pdf"

    If sFileName = "False" Then Exit Sub

    Sheet1.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFileName, Quality:=xlQualityStandard, openAfterPublish:=True
    End Sub
    Last edited by Hitori; 09-09-2013 at 04:42 PM.

  3. #3
    Forum Contributor
    Join Date
    09-20-2012
    Location
    Norge
    MS-Off Ver
    Excel 2007
    Posts
    114

    Re: How to automatically add the Value of a spesific Cell into the "Save" filename?

    Quote Originally Posted by Hitori View Post
    you can Try adding the following:

    Sub ExcelToPDF2()

    Dim iPtr As Long
    Dim sFileName As String

    If iPtr = 0 Then
    sFileName = ActiveWorkbook.FullName & ".pdf"
    Else
    sFileName = Left(ActiveWorkbook.FullName, iPtr - 1) & ".pdf"
    End If

    sFileName = Range("h8").Value + ".pdf"

    If sFileName = "False" Then Exit Sub

    Sheet1.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sFileName, Quality:=xlQualityStandard, openAfterPublish:=True
    End Sub

    Thanks Hitori, I used the following code now and it worked

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-18-2013
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: How to automatically add the Value of a spesific Cell into the "Save" filename?

    Glad That it Helps

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 9
    Last Post: 03-09-2021, 11:54 PM
  2. [SOLVED] "Save As" in current directory, filename from cell value
    By AlexCoyne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2012, 08:33 PM
  3. Replies: 0
    Last Post: 08-09-2012, 04:31 PM
  4. macro to print "save as PDF" with filename from cell
    By Eboof in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-03-2010, 08:14 AM
  5. Save as filename=(range("A1")
    By muffintop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2007, 11:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1