VBA Code For Saving PDFs To Edit Name
Jun 24, 2014
I'm working on a mac and have a macro that will go through all the sheets in my workbook and save them as PDFs to a specific location.
Sub CreatePDF()
For sh = 19 To Sheets.Count
Sheets(sh).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"/Users/mikemahoney/Desktop/Publisher Payables/Statements/June 2014" & Sheets(sh).Name & "June 2014 Revenue Share Statement" & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next
End Sub
The part in bold is obviously where I am saving the PDFs but it is also being included in the naming of the file. Need replacing the red text in the naming of the file with the contents of cell B9? I would still like to save the PDF to "/Users/mikemahoney/Desktop/Publisher Payables/Statements/June 2014" I just don't want the file-path to be included in the name of the file.
Also, this code seems to run into errors if a sheet is hidden, hence starting at sheet 19. Any way to tweak this code to skip over hidden sheets?
View 1 Replies
ADVERTISEMENT
Jan 9, 2014
I have an Excel file with multiple sheets (over 100). I want to save them each as an individual PDF, with different (but similar format) names.
As an example, I want each PDF to be be called "Date Name" (i.e. "1-8-2014 Sarah", and next one will be "1-8-2014 Beth", etc.)
Is there a way to do this all at once, instead of my having to manually save each one? Is there a way for me to set it so that the title lists the date and then, for example, whatever is listed in A1 (which will be the name)?
One other question is that because I get this report from someone else who generates it, the way the file is formatted on my computer is that the print area is set at too small, so if I convert immediately to PDF, everything gets messed up. I have to manually make the print area bigger so that the PDF version encompasses everything on one page. Right now I've been manually adjusting the print area page by page - any way to do this all at once?
View 1 Replies
View Related
Aug 1, 2013
My company has files that are already in use. I don't know too many details about how they work, but somehow saving the file will screw it up and my boss has to go back and reset something or other to correct it. Obviously it's connected to some other software somewhere. The code below will block Save and Save-As. BUT how do I get the file to hold onto the code without actually saving the file after the code is added (since the file shouldn't be saved)?
VB:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI = False Then
Cancel = True
[Code].....
View 1 Replies
View Related
Jun 3, 2009
Right now i have two worksheets:
"900 - Reel"
"OverRides"
On the "900 - Reel" sheet i have a userform ("userform4") open when double clicking a specific cell. Upon opening it uses the following code to go to sheet "OverRides" to find two specific values and imputs them into "textbox1" and "textbox2" on "userform4"
View 4 Replies
View Related
Jan 5, 2007
I have a list of worksheet names in a combobox, when selected using the drop down arrow it takes you to that worksheet. The problem is say I select "ABC" from the list and it takes me to the "ABC" worksheet but when I go back to the summary page the "ABC" is already selected in the drop down box and I cannot click it any more. Is there anyway to reset the combo box so that it goes back to the first selection of the list?
Private Sub AFISGBox_Change()
Dim strSheet As String
If AFISGBox.ListIndex > -1 Then
strSheet = AFISGBox
Sheets(strSheet).Select
End If
End Sub
View 9 Replies
View Related
Jul 21, 2006
Is it possible to enable the undo command when using VBA code in a spreadsheet? Right now if someone makes a mistake it can’t be undone.
View 5 Replies
View Related
Feb 22, 2008
How do I make this formula include searching for "ann" and "john" (in separate cells)?
View 2 Replies
View Related
Oct 13, 2008
I just wonder if we can have the code to exit if G2 returns an even number, as 2, 4, 6 etc?
Sub Listbox3_Change()
If ActiveSheet.Index 1 Then Exit Sub
Application.ScreenUpdating = False
With Sheets(1)
.Unprotect "mypsw"
.Range("G2").Value = ActiveSheet.ListBoxes(Application.Caller).Value
With .ChartObjects("Chart 2").Chart.Axes(xlValue)
If VBA.VarType(Sheets(1).Range("D1").Value) = VBA.vbError Then Exit Sub
If VBA.VarType(Sheets(1).Range("E1").Value) = VBA.vbError Then Exit Sub
.MinimumScale = (Sheets(1).Range("D1") - 0)..............
View 9 Replies
View Related
Jul 25, 2006
The way i have been creating macros is by going to the tools menu.....macro....then..... record new macro.
I have a file which I have re-formatted using a macro as described above however because i receives files every month to do updates every time i open a new file and try to perform that same macro it either wont work or it wont format the correct rows.......is VBA the solution to this????
View 9 Replies
View Related
Apr 1, 2008
I need a code to change the Macro security settings of the computer where the file is opened to enable macros.
View 9 Replies
View Related
Nov 20, 2013
I have a large number (couple of hundred) pdf's in a folder for electrical test certificates. The pdf's are in the format 54 Pike Drive.pdf etc. and have the date modified.
Ideally, as well as the address I would like the date modified as this is pretty close to the date of the certificate so will suffice.
Failing the date, just the addresses will do which need to go on separate rows in Excel.
I've tried copying and pasting the files but to no avail.
View 13 Replies
View Related
May 28, 2013
below is the code i use to create a lotus note email.
i would like it to display my email and send it manually instead of sending out automatically.
' Open and locate current LOTUS NOTES User
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
[Code].....
View 4 Replies
View Related
Dec 3, 2009
I've just created a spreadsheet that we will be using as a project review form. In this spreadsheet I have multiple rows of merged cells, column D to N, for comments. I need these comment areas, merged rows, to autofit whatever is cut and pasted or typed into them.
The first problem is cutting and pasting from a pdf. All of the documents we received for the projects we bid are in pdf format. We often cut and paste from those documents into an older version of our review sheet that was built in Word. Trying to cut and paste the same information into Excel ends up in failure. Is there a way that this can be done without jumping through hoops?
The second problem I’m running into is when I cut and paste into a comment area I get the typical Excel error message that the information being pasted does not fit the area it is being pasted into. It there a workaround for this?
My third problem is autofitting the pasted information into the merged cells. I’ve seen some VBA and tried a couple but they don’t work automatically when the comments area is filled. How can I do this? I don’t know VBA. I'm using MS Office 2003
View 2 Replies
View Related
Jan 27, 2010
I did find something related
http://www.tek-tips.com/viewthread.cfm?qid=1167426
, but as my knowledge in VB very limited I'm unable to make the neccessary modifications to fit my case.
the case:
the warehouse I'm working on is tracked by a big and messy excel file that includes details about various components.
the warehouse is virtually represented by folders that represent a drawer, each drawer includes 0-10 components's dateasheets in pdf file format.
I'm looking for a script that would hyperlink the specific pdf to each component to a certain column that includes the component's name.
there's another column in the excel that supplies in which drawer the component resides as you can see:
http://img251.imageshack.us/img251/7830/blablaf.jpg
You can also see how the drawers are represented virtually by folders with datesheets inside
components 20-29 all reside in drawer 20.
its worth noting that sometimes the whole drawer is empty and so both the column in excel and the folder will be aswell.
the script should(I assume) check the pdf's filename in the drawer( mostly the files's name look like in the screenshot), but sometimes the name is only the component's name,so if there is no drawer number before the component's name it would still know how to identify and hyperlink the pdf.
View 9 Replies
View Related
Feb 17, 2008
I have some code and then
ChDir "W:MET Logbook"
ActiveWorkbook.SaveAs Filename:= _
"Micro Evaluation " _
& Format(Date, "(mm-dd) ") & Format(Time, "hh.mm.ss AM/PM") & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub
And I want this to save my workbook in the different location as a template. Only it saves the workbook as a regular excel workbook instead. Any help with what I can change to save it as a template?
View 9 Replies
View Related
Feb 25, 2014
I have a workbook with 100 sheets and I want to quickly save each sheet as its own PDF file. I was able to find some instructions, but the code keeps giving me an error at the highlighted spot.
[Code] ......
View 3 Replies
View Related
Jan 23, 2010
I have posted already the problem to delete the code when sending a sheet via email and I have found the solution to the problem.
I tried to do the same when saving the file to specific folder, but i am facing problem.
View 6 Replies
View Related
Nov 14, 2006
if someone would review the code below and tell me why it does not cycle an autosave more than once. It is supposed to autosave automatically every five minutes but for some reason beyond me it does not. I did not author this but picked it up in a different forum.
Option Explicit
Public vartimer As Variant
Const TimeOut = 1 'set in minutes to whatever amount of time is desired
Sub Timer()
vartimer = Format(Now + TimeSerial(0, TimeOut, 0), "hh:mm:ss")
If vartimer = "" Then Exit Sub
Application .OnTime TimeValue(vartimer), "SaveOpenWorkbooks"
End Sub
View 9 Replies
View Related
Nov 1, 2013
Set up a quick piece of code to convert batches of .doc files to .pdfs
Question 1 : What is the proper syntax to add a filter to the FileDialog to only allow for .doc and .docx files
Code:
Sub DocTOpdf()
Dim s As Variant
Dim Res As Integer
Dim oWord As Object
[Code] .....
Question 2: It would seem that randomly when running the code a Run-time error -21467259 (80004005) occurs at
Code:
oWord.ActiveDocument.ExportAsFixedFormat OutputFileName:= _
s & ".pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForOnScreen, Range:= _
wdExportAllDocument, From:=1, To:=1, Item:=wdExportDocumentContent, _
IncludeDocProps:=True, KeepIRM:=True, CreateBookmarks:= _
wdExportCreateNoBookmarks, DocStructureTags:=True, BitmapMissingFonts:= _
True, UseISO19005_1:=False
View 2 Replies
View Related
Jan 23, 2014
I have a file that I want to name based on content in certain cells. I.e. "Q-(text from cell G1)-(text from cell B7)-Date(mm_dd_yy)". I want to be able to specify the location where I save this file each time I try to save it, but I want it to update the file's name if any of the parameters have changed.
I have some code generated that does just about everything right except that it automatically saves a version of the file in the folder where the original is located even though it also brings up the dialog box and allows me to save it in another location.
Basically, I want to fix the code below so that it doesn't save what appears to be a backup file each time. Should I be using some sort of savecopyas?
Code:
Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Add the quote # to the header
ActiveSheet.PageSetup.RightHeader = "Quote No. " & Range("G1").Value
[Code].....
View 6 Replies
View Related
Jan 31, 2014
I have the following macro that exports pdf's for every value in a validation list. Currently it's setup where I have included each value in the macro. This is fine with just a few values but I am about to add 900.
My question is, is there a way to write the macro so it exports a pdf for every value within a dropdown list until it hits a null value instead of what I have below so i don't have to repeat everything for every value in the list?
Here is what i currently have.
Sub Export_MarketSpecific()
'
' Export_MarketSpecific Macro
'
'
Sheets("Home Page").Select
Sheets("MOA-Page 1").Visible = True
Sheets("MOA-Page 1").Select
Sheets("MOA-Page 2").Visible = True
Sheets("MOA-Page 1").Select
Range("D2").Value = Range(Range("D2").Validation.Formula1)(2).Value
[Code] ..........
View 7 Replies
View Related
Aug 14, 2014
Adding some additional code to prevent someone from saving the workbook under a different name. Currently if someone tried to enter data after the allotted time period, it would allow them to in any "unlocked" cells. When exiting or trying to save the file with this new data, they will get a message stating something to the effect that this is a read only file would you like to save as another name, which would allow the user to circumvent what I'm trying to accomplish. The end result would be they'd need a new spreadsheet.
[Code].....
View 2 Replies
View Related
May 8, 2009
I have a workbook with lots of code to automate several things that I do. It does a great job at doing things I need it to do, but it takes foreeeveeerrr to save the workbook. The code has made the workbook a large file, and it takes a few minutes to save it. Is there a way to skip saving the code everytime you open the workbook. I don't ever need to change to code so I don't need to save it every time.
View 3 Replies
View Related
Mar 30, 2013
I am currently trying to adapt the following code which is in VBA (Sheet1). It currently ensures mandatory cell entry of cell C2 before saving, and if this is not done then it would not save the item into the relevant directory. I would like to adapt this code so that cells B2 to R2 are all mandatory, and if they are not filled in a message box with the cell title (which would be in B1 to R1) would pop up. If the cells are not filled in then it will not save (the same function it carries out for cell c2 currently). The code is attached to a command button, i have tried to make the additional cells mandatory by playing around with the If Trim(.cells(2, 3).value) part of the code with the AND function etc however i have had not had any luck.
View 7 Replies
View Related
Aug 30, 2012
Looking forward VBA coding for:
If input is entered into column C (range C2:C100), then row cells for columns D, E ,F, H or I must NOT be blank upon save.
Could be that one or more of these row cells are left blank by mistake.
An error msg pops up upon attempting to save, stops the save and colors each cell yellow that needs info entered into.
Using Excel 2010.
View 9 Replies
View Related
Jan 30, 2003
I have a spreadsheet that imports data, manipulates it then deletes 2 of the sheets then saves the file under a different name to the network. Is there any way to save this new worksheet without it storing the macros - so when the user open it, only the data is there and they get no prompt to enable macros?
View 6 Replies
View Related
Jan 7, 2009
I have created a form in a worksheet which I have added questions too and then locked all cells except the ones where I want the answers in.
I have then added a button to the bottom of the sheet called "Print and Save". This work sheet is called "form"
On a second sheet called "database", I have all the titles of the questions running from a -> k and nother else.
What I want to happen is the user input the information on "form" into the boxes available. Once they have completed the questions, I want them to be able to click on "Print and Save" so that firstly the page "form" prints, and then for all of the answers to be saved in "database" below the titles for each question.
I have had a play, but just don't know where to start. Also, once there is a row of questions below the titles, I don't want it to overwrite information already there, it needs to go onto the next empty row available.
Attached is my excel file.
You will see in the code that I have the code for printing.. I just found this on the net and it seems to work fine for me.
View 9 Replies
View Related
Jan 21, 2013
Is it possible to edit my .bat file using vba?
View 1 Replies
View Related
Jan 24, 2007
I am using Excel 2000
I have recently opened a file sent to me, and since closing it my Edit menu does not work properly when I open any existing files or start a new file
The problem is with Copy, Cut Paste and Paste Special, when I click on the Edit menu they are all greyed out, also if I right click they are also greyed out
Obviously the file I opened has changed some settings, how do I re-set this
View 14 Replies
View Related
May 27, 2008
Is there a way to setup a spreadsheet so data that has been entered cannot ne deleted or edited, and only the last field in the column can be accessible? So if I have info entered in a1, a2, a3, b1, b2, b3, no one can edit or delete them, and can only add to a4 and b4? Will I need to write a macro for this or is it something I can do with certain settings?
View 9 Replies
View Related