Creating pdf file from excel worksheet and save file in a macro created folder.

Hi I have 3 worksheets and I want to conditionally convert them into a pdf file and than save said file into a folder that the macro will create if not already existing and name it with content of cell A1. So my question is if it is possible to do that with
the following program?
Thanks.
Sub PrintStuff()
Dim vShts As Variant
Dim strFileName As String
vShts = Sheets(1).Range("A1")
If Not IsNumeric(vShts) Then
Exit Sub
Else
' Change path and filename as desired
strFileName = "C:\MyFolder\MySubfolder\MyFile.pdf"
If strFileName <> "False" Then
Select Case vShts
Case 1
Sheets("Sheet1").Select
Case 2
Sheets("Sheet2").Select
Case 3
Sheets(Array("Sheet1", "Sheet2")).Select
End Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=strFileName, _
OpenAfterPublish:=False
End If
End If
End Sub

Option Explicit
Sub PrintStuff()
Dim Path As String, FileName As String
Dim ThisSheet As Variant
Dim MySheets As Variant
Path = "C:\MyFolder\MySubfolder\"
FileName = "MyFile.pdf"
If Not FolderCreate("C:\MyFolder\MySubfolder") Then
MsgBox "Can not create folder"
Exit Sub
End If
Select Case Range("A1")
Case 1
Set MySheets = Sheets("Sheet1")
Case 2
Set MySheets = Sheets("Sheet2")
Case 3
Set MySheets = Sheets(Array("Sheet1", "Sheet2"))
Case Else
MsgBox "Uuups."
Exit Sub
End Select
Set ThisSheet = ActiveSheet
MySheets.Select
ActiveSheet.ExportAsFixedFormat xlTypePDF, Path & FileName, OpenAfterPublish:=False
ThisSheet.Select
End Sub
Private Function FolderCreate(ByVal Path As String) As Boolean
'Creates a complete sub directory structure
Dim Temp, i As Integer
On Error GoTo ExitPoint
If Dir(Path, vbDirectory) = "" Then
If Right$(Path, 1) = "\" Then Path = Left$(Path, Len(Path) - 1)
If Left$(Path, 2) = "\\" Then
i = InStr(3, Path, "\")
Temp = Split(Mid$(Path, i + 1), "\")
Temp(0) = Left$(Path, i) & Temp(0)
Else
Temp = Split(Path, "\")
End If
Path = ""
For i = 0 To UBound(Temp)
Path = Path & Temp(i) & "\"
If Dir(Path, vbDirectory) = "" Then MkDir Path
Next
End If
FolderCreate = True
ExitPoint:
End Function

Similar Messages

  • How to download a file from the net and save it into .txt format in a datab

    Can some one show me a tutorial on how to download a file from the net and save it into .txt format in a database?
    Thank you,

    http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html

  • Upload PDF file from SAP Portal and save in SAP

    A file in PDF format needs to be uploaded from SAP Portal and the file is to be saved in SAP. Request for help, how to do the same. What are the FM to be used etc..
    Thanks,

    hi
    Use FM  GUI_UPLOAD with file type as BIN
    there are similar threads...pls refer to them for more details:
    https://www.sdn.sap.com/irj/sdn/profile?userid=3166533
    Upload pdf file to SAP
    PDF File
    reward if helpful
    regards,
    madhu

  • Generate pdf file from 9i reports and save it in C:\oracle_reports\

    i want to generate a file from oracle reports in PDF format and want to save it on already defined path.
    c:\oracle_reports\
    right now pdf generation of report is working fine but before generation of pdf report system prompt me or open a dialogue box to save my pdf file on drive. i dont want to see these dialogue box or prompt me to explicitly save it.
    i want all the work done automatically.
    regards
    ------------ source code--------------
    PROCEDURE PRINT_PROC IS
    repid REPORT_OBJECT;
    v_rep VARCHAR2(100);
    rep_status VARCHAR2(20);
    pl_id ParamList;
    report_path varchar2(100);
    aud_sno varchar2(1000);
    aud_type varchar2(500);
    BEGIN
         pl_id := Get_Parameter_List('report_data');
         IF NOT Id_Null(pl_id) THEN
              Destroy_Parameter_List( pl_id );
         END IF;
         pl_id := Create_Parameter_List('report_data');
         User parameters : Customize these to fit your report
         report_path := :GLOBAL.Web_BASE_PATH||:GLOBAL.PATH_SCM||'REPORT\scm_rfq.rep';
    -- Initialize your report parameters here
         Add_Parameter(pl_id, 'p_cmp_code'                     , TEXT_PARAMETER, :global.company_code);
         Add_Parameter(pl_id, 'p_rfq_sno'                     , TEXT_PARAMETER, :document_sno);
         Add_Parameter(pl_id, 'P_PATH'                               , TEXT_PARAMETER, REPORT_PATH);
    Standard parameters: Don't change
         Add_Parameter(pl_id, 'PARAMFORM' , TEXT_PARAMETER, 'NO');
         Add_Parameter(pl_id, 'PAGESTREAM' , TEXT_PARAMETER, 'NO');
         Add_Parameter(pl_id, 'MAXIMIZE' , TEXT_PARAMETER, 'YES');
         -- end standard parameters
         repid := find_report_object('REPORT_OBJ');
         SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,BATCH);
         SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
         SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,CACHE);
         SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'rep_oas');
         SET_REPORT_OBJECT_PROPERTY(repid,REPORT_FILENAME,report_path);
    -- SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'htmlcss');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'pdf');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESNAME,'\\ORCLSRV\UTL_MAIL\'||:doc_type||:receiver_sno||'.pdf');
         v_rep := RUN_REPORT_OBJECT(repid,pl_id);
         rep_status := REPORT_OBJECT_STATUS(v_rep);
         WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
         LOOP
         rep_status := report_object_status(v_rep);
         END LOOP;
    END;

    If you use rwclient you could that easily, from a Form, it requires additional steps.
    Look at this thread Re: save report

  • Create PDF directly from Excel and paste checkboxes automatically

    Hi,
    I have a problem when creating a PDF. I want to convert a template from Excel into an interactive PDF with text boxes and check boxes. Text fields are automatically generated. Is there a way, to automatically create checkboxes? E.g. I already deliver in Excel a notice that the cell in the PDF form is a checkbox? I use Adobe Acrobat X Pro.
    Sincerely
    Ben

    Is this what you are referring to?
    http://dtputils.com/products/view/2

  • When downloading a file from google drive and save in my phones document directory,the file size is compressed. Why?

    I have downloaded files from "Dropbox" and save in phones document directory,After downloading in document directory,the size of the download file is same as the actual size in dropbox. I can also open it from document directory.Everything is ok. But when I follow the same process for google drive files, the file size is compressed(if actual size of file is 1.2Mb the download file size is 61Kb). So I can not open it from document directory.So, How can i download the actual size of the file in document directory? I am using google api objectivec client for google drive.
    Thanks in advance.

    If an iphone were to try to download a full size document ot photo, it woul overload its own ram, and crash, resulting in a laggy iphone. Therefore it is compresses

  • How do I create a DVD from existing M2V and AC3 files?

    I have previously used Compressor 4 to render a M2V file and an AC3 file from which I burned a DVD 'job'.  Now, a week later, I wish to go back and burn another DVD from these files, (without rendering them again).  How do I use these EXISTING files to create another DVD (using Compressor 4)?
    Thanks,
    Geoff

    If you anticipate that you may need multiple disks, the way to do it is to select Hard Drive as your output device/ That makes a disk image, from which you can burn multiple copies.
    WIth the separate files already created, you could bring them into an authoring program like Toast. But if you want to re-use them in Compressor, I think your only option is to multiplex them in something like MPEG STreamclip and bring the new file back into Compressor.
    Probably easier to redo the Compressor job with the original source.
    Russ

  • How to download a file from a website and save it locally

    Hi people,
    I have a number of URLs at hand that point to certain class files, e.g.
    http://www.mywebsite.com/classes/MyClass.class
    What i would like to do is to download MyClass.class into a temporary folder on the local disk. Does anyone know how to do this? I've read about HttpURLConnection etc., but its all very confusing!
    Cheers,
    JG

    you need to create a URL to the url
    URL url = new URL("http://www.mywebsite.com/classes/MyClass.class");
    HttpURLConnection c = (HttpURLConnection)url.openConnection();
    then you need to acquire an input stream from the connection. Roughly this is
    InputStreamReader r = (InputStreamReader)c.getInputStream();
    FileWriter w = new FileWriter("c:\\temp\\" + name);
    int b;
    while((b = r.read()) != -1) {
    w.write(b);
    close all streams
    something like this - will let you work out the rest..dont forget to try/catch all the IO exceptions.

  • Not able to access files from Workspace Images and Static files

    Hi,
    We have just migrated our APEX Application from one server to another.
    All the functionality is working fine except the images or files which we are uploading
    in
    Shared Components -> Static Files
    Shared Components -> Images
    We are uloading Images in Shared Components -> Images but those are not getting displayed there.
    Similarly the files which we are uploaded in Shared Components -> Static Files are not accessible. If we
    try to download using download icon its showing blank screen.
    I am using some javascript files which i have uploaded into static files, but not able to refer them in page.
    Please someone guide us how to resolve the above problem.
    Thanks in advance.
    Thanks & Regards
    Sanjay
    Edited by: user11204334 on May 25, 2010 1:35 AM
    Edited by: user11204334 on May 25, 2010 3:45 AM

    Hello Sanjay,
    If you upload any static files such as IMAGES, FILES, or CSS you have to use the tags: #WORKSPACE_IMAGES# or #IMAGE_PREFIX# depending on your files location..
    then try something like htp.p ('<img src="#IMAGE_PREFIX#fileName.gif" />');
    And it should show the fileName.gif on your browser...
    I am not sure if i remember correctly, you can reference files to a specific application or to the whole application, if I am not mistaken..Correct me..
    Regards,
    Noel Alex Makumuli,
    Tanzania

  • TS1474 i tried to add music files from portable drive and the files are not found

    now the drive is corrupt and unreadable
    what do I do?

    You can only add music from iTunes.

  • Problem Creating PDF Files from Excel 2007

    I am running WinXP SP2, Office 2007, and Acrobat v8.1.2. I have an Excel workbook with multiple worksheets. When I was using Excel 2003 I could create a PDF file using five of the six worksheets. Since upgrading to Office 2007 I am unable to create PDF files from Excel. I can create PDF files from Word 2007. When I attempt to use the Acrobat Plug-in to create a PDF I get a message saying the file needs to be saved first. It then attempts to save the file to a strange, somewhat random, file name (e.g. A234G53). When I say OK Excel just hangs and is unresponsive. The way that I can clear it is to stop Excel using Task Manager. I have tried reinstalling Acrobat without successfully solving the problem. Any ideas on how I can diagnose and/or solve the problem?
    Thanks.

    Is your Excel file on a location outside your machine's disk? If so, try copying to local disk.
    Does the Excel file have any protection applied to it? If so, try removing the protection
    If these don't work, can you post a sample file that demonstrates the problem.

  • Create PDF button gone from Excel worksheet

    Recently had to restore computer back to factory. I installed full CS4 WebSuite which includes Acrobat. I used to have a PDF button in Excel that would let me create a PDF from an Excel worksheet. How do I get that back? I used to use Office 2003 and now I use Office 2013.
    Thanks so much in advance!

    The store is at http://www.adobe.com/products/acrobatpro/buying-guide-upgrade-pricing.html. If you click the upgrade option, you will see the option to upgrade to AA XI from the AA X Suite (whatever that is, I assume CS) or from individual products. In your case it is not an individual product, but a suite. If you have questions or want to see if you can get a deal, you will have to call the Adobe sales folks. We can only repeat what we see and have heard from others (except for those folks who have the suite).
    You can still print to the Adobe PDF printer from Excel 2013, if you can get AA9 to work on Win8 (an outside chance, but may require some workarounds). You would just not get links or bookmarks. You might see if there is a MS plugin for creating PDFs from Excel. If there is, you might be able to create the PDFs that way and edit in Acrobat 9.

  • Is there a way to open Excell file from the server and display in the UI and save it back on to the

    Hello there,
    Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)

    Hi Mike,
    Welcome you to the forum.
    You may try:
    SELECT * FROM MyDBNameHere.dbo.OUSR T0
    Thanks,
    Gordon

  • I want read PDF file from SAP directory and create a spool request or print

    Hi all,
    I want read PDF file from SAP directory and create a spool request or print the pdf through SAP. Can any body  help me in this.
    Also please write to me if its possible to open PDF from SAP directory to adobe pdf reader.
    Thanks in advance,
    Sunny

    Hi Sunny,
    Check these links.
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    http://www.erpgenie.com/sap/abap/pdf_creation.htm
    http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
    http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Will I be able to create fillable pdf forms from existing word and excel documents?

    Will I be able to create fillable pdf forms from existing word and excel documents?

    Hi
    Yes you can. You may visit this link to check the workflow: https://www.youtube.com/watch?v=O0PPzFq3X00
    Regards,
    Ajlan Huda.

Maybe you are looking for

  • Difference btw table and structure???

    Hi all guru's What is the difference between table and structure?? culd you explain me??? regards ss

  • Print in foreground for 4 alv using splitter

    hi All, I have created a program which displays 4 different alvs on a single screen . I have used one container and 4 splitters to display the alv. after the program is executed ,there is a button (print) through which all 4 alvs should be sent to a

  • IPhoto 6.0.6 Hangs Every Time

    Every time I try to open iphoto (6.0.6) it crashes. It gets to "loading photos..." then disappears and I then get the "application quit unexpectedly" dialog box. It's been doing this ever since I first got the mac (mini, 1.66 Intel core duo, 512MB, O

  • Oracle 11.2.0.2 and nchar optimizer problem

    Hello, sorry in advance for not being able to give all details to narrow better this possible problem. I admit it could be elsewhere..... I have a complex query where in particular an nchar(2) field (say col1) of table tab is involved I'm experimenti

  • A Report who finds WBE in set with a massive sort criteria

    Hi, I'm looking for a Report who finds WBE in sets  (Groups) with a massive sort criteria because KJH3 has only a "one by one" sorting criteria. Thanks Giovanna