Free Microsoft Excel 2013 Quick Reference

Read & Save PDF File In VBA Macro

Hi All,

I am looking for code in excel vba that will open a pdf file and save a copy of it in a different location and return to excel o repeat this process. "FollowHyperlink" method works only to open the pdf, but how do I make it to save in a different location. I do not have pdf writer so "AcroExch.App" object does not work either.

I would appreciate if someone can really help me here.

Thanks,

Peace


I have some embedded PDF files in Excel file. I want to save them in a separate folder as seperate files, by pressing a button in toolbar.
How to do that using VBA?

Thanks

Is there VBA code to click 'yes' to save data on clipboard when closing an Excel file in a macro? The macro allows to choose a unique file each time and copies specific information and I want the macro to close file but keep the info on the clipboard to paste into the main data file where the macro is stored. I cannot seem to find the code to click 'yes' for this option. Any suggestions??

Thanks,
Colleen

Hello!
I want to read Data from external XLS-File in VBA like VLookup does on a worksheet!

How can I do it?
with what command?
Is there someone who can help me?

I want to put the data in a variable...
here some code:

Option Explicit
Dim oCode As Integer
Dim oFile As String
Dim oSheet As String
Dim oBundesland As Variant
Dim oBland As Variant

Sub getPLZnetData(oCode)
Application.EnableEvents = False
oFile = "F:MarketingAdd InXLSlibPLZ.xls"
oSheet = "PLZ"
Workbooks.Open Filename:=oFile
oBundesland = VLookup(oCode, "A1:C29390", 2, False)

Application.EnableEvents = True
End Sub

Greetz

Dimi

I am trying to find out if there is a way to automatically find out if there are files in a directory and delete them so I can remove the directory. I want to do all this through a macro in VBA. Another possibility is to error check and if the error happends then do something else but I cannot figure out the If Statement for an error code 75 or 76. My final program will be a startup program on a disk so that the user can run the excel program by choosing what Excel programs they want on their computer and the program will make the directories and load programs in those files. I can make the directories and move the files but my problem is that if the directory already exists then aI get an error. I know this is a lot to check for not much of a good reason but I try to check for everything. I will be thankful for any help.

I have a Master Workbook, which has VBA to save as someone where else with a different name.

But I need to add something to the VBA code that clears out the data, based on the workbook's name.

Basically on start-up, IF the workbook's name is "Days to Invoice", then run CLEARALL Macro..

If the name is anything other than "Days to Invoice" I need it to be read-only.

Which leads me to another question..
How do I save a file in VBA to read-only?

2 questions in one post, woohoo

Hi all,

I would post in http://www.ozgrid.com/forum/showthread.php?t=65530, but the topic was already closed. There is a slight modification that I'm looking for in the posted code, and that is to only list PDF files in a folder, as well as truncating the .pdf portion of the filename. I am pretty new to VBA coding and plan on becoming an expert at it, but you have to start somewhere!

Thanks in advance for any and all advice.

Hi,

I am generating a pdf file through vba excel. I am now able to generate pdf through code.
Application.ActivePrinter = "PDFCreator on Ne00:"
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:="PDFCreator on Ne00:",
Collate:=True
but after this line gets executed, pdf creator throws a dialog box asking to modify the name of file and location and then press button "save" or "cancel" to save the pdf file.
I need to have code which will modify the name and location and then it will press "save" button on the dialog box.
Thanks for reading this post.
Thanks
Abhijeet

i m going to add some shortcut key and some VB into my excel file, but it must enable the macro. I want to know is that safe if i save the file in macro-enable" ? What will be happen?

thanks

I'm (trying to) write a macro that will request the user to "save document as" in order for him/her to save the document wherever he/she wants but I can't seem to figure out what VB code I need to just have that "save as" box and let the user decide from there.

Ideally I would like the macro to:

Do the rest of what it's supposed to do after the user has saved the document
OR
Stop if the user clicks "Cancel".

Is there an easy way?

Thanks!

Hello All,

I have the following code that saves a certain file in Excel 2003:

BlahBlahBlah.SaveAs Filename:="YaddaYaddaYadda.xls"

After this code is executed it saves the file in the default format of Excel 2007. Is there a command to replace the above ".SaveAs" that can be used to save a file that is compatible with Excel 2003.

Thank you.

I would like to know how can I can I execute a batch job in VBA macro?

for exemple: I have an external text.bat file that can be run in command window.

Thanks in advance,
Mark

Hi All,

I have a quick question, i need to save a file in a macro, form CSV to XLS however, my code is keeping the file extension as part of the name... how can I rename this as a .xls using only the first 10 letters of the name?

Here is my code:

Sub BulkFileDownload()

file = ActiveWorkbook.Name
Dim filenames As Variant
Dim Name As Variant

'SELECT MULTIPLE FILES
filenames = Application.GetOpenFilename(, , , , True)
Counter = 1

While Counter

Need to link excel "cell" to a pre saved PDF file?? How do I do this??

Hyperlink is not the answer. I want a cell to have ## in it and then when
clicked on it will pull up the pDF I have saved in a different directory!
--
Red

Need to link excel "cell" to a pre saved PDF file?? How do I do this??

Hyperlink is not the answer. I want a cell to have ## in it and then when
clicked on it will pull up the pDF I have saved in a different directory!
--
Red

Hi,

I am looking for a macro to rename the pdf files in a folder.

Say I have 100 pdf files in a folder 1-100, I need to rename the file to the list I have in excel. For example file name 1 should be renamed to "invoice 1" which I have it in excel spreadsheet. Similarly file name "2" should be renamed to "Invoice 2".

Please help!

Regards,
Vijay

I have a macro that launches word or excel files if the file address (e.g. C:Documents and SettingsHenryDesktoptest.xls) is typed into cell A1 by looking at the last 3 letters of the file name.

I cannot find a way to enable it to launch pdf files as well (e.g. C:Documents and SettingsHenryDesktoptest.pdf)

The code is as follows:

Sub
LaunchLink()

    Dim myFileName As String
    Dim myFileType As String
    
    On Error GoTo Errorhandler
    myFileName = Range("A1").Text
    myFileType = UCase(Right(Range("A1"), 3))
    
    Select Case myFileType
        Case "XLS"
            Workbooks.Open Filename:=myFileName
        Case "DOC"
            Application.DisplayAlerts = True
            Set appWd = CreateObject("Word.Application")
            appWd.Visible = True
            appWd.Documents.Open Filename:=myFileName
         End Select
    Exit Sub
Errorhandler:
    MsgBox "File does not exist. Please check with Administrator"
Any ideas would be much appreciated

Thanks

Henry

I wish to open a pdf file using vba. Does anyone know whether this can be done?

Hello,

Is it possible when saving a file in vba to add the current month/year to the end of the filename with the format mmm/yy?

The code I have so far.....

Workbooks("test.xls").SaveCopyAs ("C:xls
filestest.xls")


I need the month/year to be added to test.xls so that it looks like "test_Oct-07.xls"

Thank-you in advance

Hi all ,

I want extract the text from the Pocket Excel file in Pocket PC.
Is there any API to read pocket excel files in comapct framework?

Thanks

Dhananjay

I have to move through at least 5 folders just to get to the folder I want to
save my file in, why cant Excel or any other application remember where I
saved last and just take me there?

I have created a series of hyperlinks to PDF files in my Excel file. But when
I click on it, Adobe starts and then closes immediately without opening the
PDF file. For hyperlinks with Office documents (such as Word or Powerpoint)
this problem does not occur.

On the Microsoft support website, it says that this problem occurs if Adobe
Reader 7.0 is installed on the computer, and the problem can be solved by
installing the 7.0.1 update.

I am using Adobe Professional 7.0, and the "Check for updates now" is
telling me that there are no updates available. Is there anything else I can
do? Thanks.

Hi

Sorry if this question has been asked already and I've missed it....
I've written a script to read all the values in an excel worksheet in to an array. The cell types differ from General or Text to Custom - HH:MM
When I look through the array the script has returned the correct value for most but for the cells that are of a custom type an "incorrect" value has been returned.
For example a cell of type Custom HH:MM which is 10:23:00 in the worksheet appears as 0.432638888888889 in the array. Is there a way to get the script to return the correct value?

Below is an extract of the code I've used

	VB:
	
 
    If objWorksheet.Cells(i, "F")  "" Then 
        arrCULDEV = Split(objWorksheet.Cells(i, "F"), ":") 
        Redim Preserve arrSheetInfo(x) 
        arrSheetInfo(x) = arrCULDEV(0) & "," & arrCULDEV(1) 
        x = x + 1 
        i = i + 1 
    Else 
        i = i + 1 
    End If 
End If 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
Thanks

Hello I would like to save a file in two different folder at the same time

original folder is My documents
ex:
C:My documents (and under sufolder) Perso
D:Backup

Backup will remain close
Thanks for the help

Using Mac, OS X 10.3.9, Excel X for Mac.

I need to write a text file in VBA with a Unix line break (ASCII 10 / x0A).
I'm iterating over a range of cells and writing out lines with:

Print #FileNum, Cell.Text & Chr(10)

Anyway, when I get my file written out, it's not performing as I expected. I
did a hex dump with TextWrangler and found that I'm not getting a linefeed
character written out. Here's a sample hex line:

0050: 00 0D 00 0D 00 64 00 69 00 67 00 20 00 31 00 39 .....d.i.g. .1.9

The first two characters should be a single line feed (x0A), but I'm getting
a double carriage return (x00 x0D).

Two questions:
1. It looks like Excel is putting out double-byte ASCII (all the extra 00 in
front of the actual ASCII characters). Is this correct?

2. Why am I getting ASCII 13 / x0D when I'm explicitly writing out ASCII 10
/ x0A?
-------------------

P.S. I discovered that some common Mac VBA constants are not as expected:
vbCr 13
vbCrLf 13
vbFormFeed 12
vbLf 13
vbNewLine 13
vbNullChar 0
vbObjectError 45
vbTab 9