Solved

In VBA, create workbook name with ".pdf" as a default name

Posted on 2014-10-01
2
205 Views
Last Modified: 2014-10-01
I'm using the following codes to create a pdf file from xlsm file, but I got this shown up in the default name window - "CNS WC KE Tool Updated 9-29-14.xlsm20141001_1026.pdf".  How can I remove ".xlsm" from the default name window?  Thanks.

strFile = Replace(Replace(ws.Name, " ", ""), ".", "_") _
            & "_" _
            & ActiveWorkbook.FullName _
            & Format(Now(), "yyyymmdd\_hhmm") _
            & ".pdf"
   
FolderName = "C:\Users\" & User_Name & "\Desktop\"
strFile = FolderName & strFile

myFile = Application.GetSaveAsFilename _
    (InitialFileName:=strFile, _
        FileFilter:="PDF Files (*.pdf), *.pdf", _
        Title:="Select Folder and FileName to save")
0
Comment
Question by:jjxia2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40354869
Change the third line, ActiveWorkbook.FullName, to

Replace(ActiveWorkbook.FullName,".xlsm","") 

Open in new window

0
 

Author Closing Comment

by:jjxia2001
ID: 40354928
Thanks!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question