Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How To Open PDF Files Via Visual Basic Macro Code ?

How can I code a Macro in Excel to search in a preset directory and pull out, aka open/run
a certain Adobe Acrobat .pdf file automatically?

Is this even possible to code in Excel Macro or is it out of its scope of what Excel VB code can do?

Right now I have a very repetitive task where depending on the value of a certain field in Excel I have to search for the right/corresponding .pdf file and open it up do work in the .pdf as well as the Excel worksheet... I have to do like hundreds of this....

So is there a quick way to code in Excel that a certain value will open a certain file named .pdf acrobat file? Can other programs/files be called upon and ran/started/opened from within Excel Macro?


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Open Word Document With Macro Disabled From Visual Basic

I have another problem. I need to open word documents from a program in Visual Basic in order to parse them but some of these documents have macros in their open method and i don't want to run them when i poen the documents. How can I do this? Is there a property in the word.application object?



What Code Can I Use To Automatically Open A Visual Basic Code When I Open Excel?
I tried to write auto_run at the top of the code. It doesn't work though. is that the right one? if it is where am i supposed to put it?

Finding Text In Open Files Using Visual Basic
Hi all, I hope someone can help me with this.

Basically, I have two text files (which I will call for arguments sake file1 and file2).   File1 contains a long list of registry keys extracted using regedit and file2 contains a similar set of keys, also extracted using regedit but from a different machine.

What I need to be able to do is compare the two data files to see what keys are different between the two machines. At present I read in the two data files and write them to a database, but this is extremely slow and indeed crashes when trying to compare two HKLM subsets(which is not surprising really).  I have come up with an idea of reading in the first file and each time it comes to a new key checking to see if it exists in the second file, i.e

Read in Key 1
    Does it exist in File 2?
         If no, then write error log
    Otherwise continue
Read in Key 2

etc, etc.

What I need to know is if there is any way of finding a particular text string in an open file.   At present I am using the standard VB Filehandling functions, (open "filename.txt" for output as #1 etc), but if there is a better way then I would appreciate it.

Any help or advice would be useful.



How To Use Visual Basic 6 To Open A Few New Window,and Get Their Html Code
how to using visual basic 6 to open a few new windows,and get their html code then write some data into a database?for example,i want get the"

page's can i do?
thank you

Howto Open Cashbox Drawer Of Cash Register Using Visual Basic Code

im developing a point of sale system for the first time but i know a bit how develop database system using visual basic and mdb and i plan implement on the network and my question are:

- using visualbasic code how can i open cash register drawer?
- does cash register printer the same as the usual printer?

Extracting Visual Basic Source Code From Visual Basic EXE
hi everyone,

Well actually the problem in my case is that i had mad an EXE in VB6 around a week ago and had stored the EXE and th source code in two diferent folders. By mistake somebody ha deleted the source code folder. I wanted to make some changes i the EXE code and Now i have only the EXE folder to deal with.

Is there any method by which i can extract the Visual Basic cod from the VB EXE. Is there any application or software which ca help me in this? Do give me the hyperlink for downloading th EXE for the extraction if possible.

Please let me know at the earliest.

Thanks in advance.


Visual Basic Macro Help Please
Hello All,

I have recently been working with an excel sheet I got a long time ago for Fire Sprinkler calculations.
On the excel sheet it has 2 buttons linked to macros done in Visual Basic.
The macro switches on and off a calculation section using the following code.

Sub CheckBox16_Click()
Call allow
End Sub

Public Sub allow()
If Cells(103, "A") = True Then
If Cells(100, "A").Value = 1 Then
Cells(102, "A") = 25
Cells(102, "A") = 50
End If
Cells(102, "A").Value = 0
End If
End Sub
I have know idea of Visual basic and need to understand what to type in the excel sheet to get this other section working.
I hop this is the correct section in the forum for it and somebody could give me some guidance.
Edit by italkid: Please use the [vb]][ and [/vb] tags to display your code, thanks.

If, Then, Else Visual Basic Macro

Hi All!

I am trying to create a macro to run in Excel that will look at a value and hide columns based on the value. When I try to run this the Macro is only looking at the last Else statement and is ignoring the "ElseIf" statements. I have attached the code below. Can someone please take a look and let me know what I am doing wrong

Sub Using_If()
Dim x As Integer
x = Int(Worksheets("Funding Sheet").Cells(8, 12))
If x = 7 Then
Worksheets("Page 5").Select
Selection.EntireColumn.Hidden = False
ElseIf x = 6 Then
Worksheets("Page 5").Select
Selection.EntireColumn.Hidden = True
ElseIf x = 5 Then
Worksheets("Page 5").Select
Selection.EntireColumn.Hidden = True
ElseIf x = 4 Then
Worksheets("Page 5").Select
Selection.EntireColumn.Hidden = True
ElseIf x = 3 Then
Worksheets("Page 5").Select
Selection.EntireColumn.Hidden = True
ElseIf x = 2 Then
Selection.EntireColumn.Hidden = True
Else: MsgBox "Go to page 6 to enter more than 6 assets."
End If

End Sub

Open PDF Through Visual Basic Only Works When Acrobat Prof 8.0 Instance Is Open
Hi all,

Something strange happens to my code (it used to work correctly in the past).

When executing next sample code:

Code:Dim ac_App As Object
Dim ac_AVDoc As Object

Set ac_App = CreateObject("AcroExch.App")
Set ac_AVDoc = CreateObject("AcroExch.AVDoc")

ac_AVDoc.Open "c: emp.pdf", "Test"

I get error message:

Quote:Run-time error '-2147024875 (80070015)'
Automation error

When Acrobat Pro 8 is running everything works fine.

With some sloppy programming I resolved my problem (see code below), but this doesn't seem right to me.
Does anyone know what the reason could be for this?

Code:Dim ac_App As Object
Dim ac_AVDoc As Object

Shell "C:Program FilesAdobeAcrobat 8.0AcrobatAcrobat.exe", vbHide

Set ac_App = CreateObject("AcroExch.App")
Set ac_AVDoc = CreateObject("AcroExch.AVDoc")

ac_AVDoc.Open "c: emp.pdf", "Test"

I've allready checked my register and AcroExch.App, .PDDoc, .AVDoc, etc.. are registrated.
Although, I noticed that there is also an instance of AcroExch.App.1 etc. registrated. Could this be the issue?
(see screen capture of registry in att.)

Hope anyone can help me, 'cause it's getting messy here at the moment !

Thanks in advance.


Edited by - DoLoop on 5/30/2008 9:20:54 AM

How To Run An Excel Macro From Visual Basic 6
I posted a few minutes ago, but I may be able to solve the problem I',m having if I can have visual basic tell Excel to run a macro every 10 seconds.

Any way I can do this?

Any help is greatly appreciated,


Visual Basic Macro Counter
hey, just wanted some help with something, Im trying to make a macro in visual basic, I want it so that everytime I click a button, on another page it adds 1, example, I press Coffee button on orders page, on another dummy page I want it to say in cell A1 Coffe and next to it 1, every time I press that button the number increases by one, press the buton 10 times, the number 10 is next to Coffe. Its so I can make a product graph for how many of a certain item has sold so I can put it into a bar graph. Thanks for reading

Run A Macro In Word Using Visual Basic
how can i run a macro in word using visual basic. if it is possible pls help

Visual Basic Excel Macro
I am trying to to Create A Macro that when its is ran it will copy whats in Column L to Column D. But it has to be the contents that are in every other 24 cell of Column L to Column D. So it would be L1, L25, L49 to D30, D31,D32....
I know im gonna need a For Loop and Im gonna have to set the string to an int since whats in the cells are strings. This is what i got so far and if anywon can lead me in the right direction I would appreciate it. Thanks

Dim strNumber As String
For i = 30 to 352
strNumber = i
Range("L" & strNumber).Select
Next i

I Need Help In Macro Visual Basic Excel
I use the mecro to print data in the cells of excel
so I put this code : cells .cells=8 for that, it print the number(5)
in all of the cells
I want to print in specify cells like : a1, b2 ..etc
how caN I DO that.
and thankyou for help

Visual Basic Macro Creation
I need help in completing a macro using visual basic. The macro takes data from and excel spreadsheet and places it into another application. I have data in multiple rows in the excel spreadsheet. What I need is to be able to have this macro choose the data in one row, move it to the appropriate application, and then continue and choose data from the next row and to continue until it reaches a * or other symbol at which time the macro stops processing.

I would appreciate any help you could provide in getting this working for me.


How To Run Macro When Call In Visual Basic?

Hi Everyone,

Does anyone knows how to call/run macro using visual basic 6.0?

I have an existing document with macro on it. I've tried to make a new project in visual basic 6.0. I've created new button in the form. If I click that button, it should automatically call the document and should automatically run the macro when opening that document instead of clicking the tools--->macro-->macros-->run. Please help me...

Thanks guys!!! =)

Execute Access Macro From Visual Basic Using ADO
does anyone know how to execute Access Macro from Visual Basic using ADO? I tried using the Connection object and Recordset object.

I'm open to any suggestions.

Visual Basic Calling An Excel Macro?
Is it possible to have Visual Basic call a macro from excel?

Execute Ms Access Macro In Visual Basic
Hi, can anybody tell me how that you can execute / call a macro that has been created (before) in MS access, in my visual basic program

thx in advantage

Executing An Access Macro From Visual Basic
How can I call and execute an MS Access Macro from within a Visual Basic Program?

Creating Visual Basic Macro In Outlook
What VB code would I need in a macro to automatically empty my
junk E-mail when I open Outlook 2003? The junk E-mail option to
permanently delete suspected junk E-mail instead of moving it to
the junk E-mail folder does not work. I was told by IT that this
was a bug with Outlook and they are trying to resolve with
Microsoft. Who knows how long that will take...



Read Excel Macro In Visual Basic
How to get the defination of a macro in visual Basic?
Suppose there is a Excel file with a macro named as 'Macro1'.
Throgh VB I want to check if this macro defination has any word "Execute" in it. How can this be done?

Visual Basic Macro In Excel 97 For Submitting Data
Basically I've got a form and a form button and I need a macro to submit the data entry value from certain cells to a hiddent able i've made. But then when another set of data is submitted by the button it then enters the data below the the previous submitted data and so on.

Here are the references to the cells with values that need to be entered into the table:
"B7:C7", "A10", "B12,C12","B13,C13","B14,C14".
The button is a normal Excel form button, though this could be changed into a Command Button if necessary.
The first cells into which I want to enter data are as follows, they are in the same order as above i.e. 1st above inputted into first below:
"A21:B21","C21", "D21:E21","F21:G21","H21:I21"

This is for my A level IT course and my teacher, who's the only one in the school who knows how to do this, won't tell me as he's going to teach it to us in a few months time - but I can't wait, I need it now!

Please someone help me!

How Do I Print An Already Existing PDF File From Visual Basic Macro
I'm trying to print an External Existing .PDF doc from within my Visual Basic Macro. How do I do it? I know how to do it using batch files, would I have to call a batch file from VB, if so how would I do that?

Thanks everyone!

How To Call A Excel Macro From A Visual Basic Program
Dear All,

I want to call a Excel macro from my visual basic program.
I am using the following code

Set Excelapp = New Excel.Application
Set xlbook = Excelapp.Workbooks.Open("C:abc.xls")

Excelapp.Run "macrofunction()"

But on execution of the Excelapp.Run "macrofunction()" it gives error that macro "macrofunction()" not found.

Can anyone guide me through this process. Hope someone has answer to this.


Confirmation: Creating Visual Basic Macro In Outlook #529272
======== CUT HERE =========
This is a receipt that your ticket was successfully received:

Created: May 6, 2005 6:47:40 AM
Last Mod: May 6, 2005 6:47:40 AM

[May 6, 2005 6:47:40 AM]
Q: # View the results of the IP Telephony/VoIP Deployment Survey

# View Group Archive:

What VB code would I need in a macro to automatically empty my
junk E-mail when I open Outlook 2003? The junk E-mail option to
permanently delete suspected junk E-mail instead of moving it to
the junk E-mail folder does not work. I was told by IT that this
was a bug with Outlook and they are trying to resolve with
Microsoft. Who knows how long that will take...



************************************************** *************
*Manage Subscriptions:
*Leave Group: mailto: email@removed
*Need Subscription Help? mailto: email@removed
*Terms of Use:
*Copyright (c) ITtoolbox and message author. No redistribution.

{Unresolved} Can I Call An Access Macro From A Visual Basic Project?
Can i call an Access macro from a Visual Basic project? If so, how? Thanks! - lpj

Edited by - Shandy on 4/19/2004 9:08:23 AM

Visual Basic Macro To Create A CSV File In Excel Through Project

I am trying to run a macro in Microsoft Project then opens an excel file and then saves then saves it as a csv file. I have declared XL. as a excel object and therefore this begins every line. I have then used the following command:

XL.ActiveWorkbook.SaveAs FileName = "C:Documents and SettingsDesktopTestScript3.csv" & FileFormat = xlCSV

But instead of creating a file called TestScript3.csv it creates a file in My Documents called TRUE.xls or FALSE.xls. Can anyone tell me why this is?



Code Change From Visual - Visual Studio 2005
I am working on a tuturial that i have for Visual ( for now )

I am working with Visual Studio 2005.

I have been working on a code to change the text color by the name put into
the text box.

Visual Basic .Net code.
Label2.ForeColor = Color.FromName(TextBox1.Text)

i get the error
Name 'Color' is not declared.

I was wondering if someone can show me how things would be in Visual Studio.

thank you

URGENT Help Required Basic Visual Basic Code
How do I bring up records from a list box??? this is what I have so far of my programming...

Option Explicit
Dim FileName As String

Private Sub cmdAddFileWrite_Click()
Dim Name As String
Dim Age As String
Dim DOB As String

Name = txtName.Text
DOB = txtDOB.Text
Age = txtAge.Text

Open FileName For Append As #1
Write #1, Name, DOB, Age
Close #1
txtName.Text = ""
txtDOB.Text = ""
txtAge.Text = ""
End Sub

Private Sub cmdDisplay_Click()
Dim DataToDisplay As String
Dim Name As String
Dim Age As String
Dim DOB As String

Open FileName For Input As #1
Do While Not EOF(1)
Input #1, Name, DOB, Age
lstdisplay.AddItem Name

Close #1
End Sub

Private Sub Form_Load()
FileName = App.Path & "AddPlayer.txt"
End Sub

That is wha I have so far I mean I have a list box there where it displays the data that has been inputted, now how do I get that to link up wit a record something to do with a module?

Visual Basic Macro - Create Email Insert Data From Excel
I am looking for a solution to do the following (and have searched and searched and have not found an answer.)

I need to have a macro that generates an outlook email from data listed in an excel spreadsheet. Not only will this macro need to read data from a column containing email addresses (a list of recipients), it will need to insert excel data listed in different workbooks of a single spreadsheet. The data that needs to be inserted will vary from receipient to recipient - i.e. will not be the same length or content for each email.

I need to know if this will be possible - I do have a simple, generic macro listed below that will create a form letter - but I am not certain if this can be changed to allow a. different excel content and b. email support. Any help would be very much appreciated.


Sub Do_It_All_Form_Letter()
Dim word As Object

Set word = CreateObject("word.basic") 'creates the word object

With word
.AppShow ' Makes Word Visible

'Sends keystrokes to the Open Worksheet dialog box
SendKeys "{TAB}{TAB}{TAB}{ENTER}"

'Opens the Microsoft Excel file
.FileOpen Name:="c: estdata.xls"

'Saves the file as a Microsoft Word document
.FileSaveAs Name:="c: estdata.doc", Format:=0

.FileClose 'Closes the file
.FileNewDefault ' Opens up blank Word document

'Makes the active window a main document
.MailMergeMainDocumentType 0

'Open the data source
.MailMergeOpenDataSource Name:="c: estdata.doc", _

'Activates the mail merge main document

'The following Insert commands place text into the Word
'document. You could change these commands to place any text in
'the document. This example uses a typical business letter

.Insert "3454 Blindside St." 'Inserts a string
.InsertPara 'Inserts a carriage return
.Insert "Columbia, GA 23287"

'the mergefields are the same as the column headings in the Excel
.InsertMergeField MergeField:="NAME"
.InsertMergeField MergeField:="ADDRESS"
.InsertMergeField MergeField:="CITY"
.Insert ", "
.InsertMergeField MergeField:="STATE"
.Insert " "
.InsertMergeField MergeField:="ZIP_CODE"
.Insert "Dear "
.InsertMergeField MergeField:="NAME"
.Insert ","
.Insert "Thank You For Your Support."
.Insert "Sincerely,"
.Insert "John M. Doe"
.MailMergeToDoc 'Merges data records with the main document
' Saves the active document with the specified name
.FileSaveAs Name:="c:letters.doc"

End With

Set word = Nothing 'clears the object variable

End Sub

Open Url Visual Basic

I would like to open an url with properties in pure visual basic code.
I know how to do that with vbscipt:
Dim url
url = ""
Dim hWindow
hWindow =, "ident","scrollbars=no,resizable=yes,toolbar=no,directories=no,locatio n=no,status=no,menubar=no,left=10,top=10,width=300,height=300" )

The function isnt recognize in vb.
How can i translate it into vb ???
I know that we can do something like this:
Dim rep
Dim url As String
url = ""
rep = ShellExecute(hwnd, "open", url, vbNullString, vbNullString, 0)

Open GL In Visual Basic

i just started getting into trying to use open gl and i cant find how to declare the open gl functions, i have added them to my project lib' but i just dont know how to declare them/make them work, if anyone has a link to some good tutorial or can point me in the direction of how to do this it would be great.


Open GL In Visual Basic
Actually I have an Active X control of open GL provided by Waite Superbible of Open GL.

After registering the control with VB 6.0, i have written some code in visual basic using this Active x control. Although program is not giving any error during run time but it is also not carrying out any code that i have written. i don't now what is the problem. Please help me, it' is urgent.

Combining Visual Basic And Visual C++ Code
I need to embed C++ code in my Visual Basic project without using a DLL.
I understand it's something to do with the linking process and it is described here:

However, I don't seem to have the 'Compile Controller' add-in that it talks about. Can anyone tell me either where I can find this add-in or how I can embed a C++ function in a VB project

C++ Code To Visual Basic .net Code (32bit To 16bit Variables)
How do I change the following code to visual basic .net code...

long val;
long lowpart;
long hipart;
long table[9];

val = table[0];
lowpart = val & 0x0000FFFF;
hipart = val & 0xFFFF0000 >> 16;


How Do I Convert Wav Files To Midi Files With Visual Basic?
Please Help Me!!

I need to convert wav files to midi files with visual basic. Does someone know how to do it?



Maria Lorena López

How To Open PDF File From Visual Basic
Please Help me to solve the problem.

I want to Read data from PDF file to Visual Basic Form and I want to send some informaiton to PDF file. What will be the code for it.

Open A Webpage Within Visual Basic 6
Is there anyway through a button click that the user can open a webpage within a form. Say im going to need the link in the code.


Open Programs In Visual Basic
Is there a way to open up programs from VB. I wish to Open up Nero Showtime in Visual Basic. How could I do this. Also, Is there a way to restore programs already in the windwos task bar.


Open Outlook From Within A Visual Basic App?
hey, i would like to know what command i need to use so that when i click a command button, outlook will open? can this be done?

Open .pdf File From Visual Basic
How can i have my program open a .pdf file? The user should already have Adobe Acrobat Reader installed on their machines...

Also, are there any free (or reallly cheap) pluggins to allow my program to open a .pdf file without having to open the external program?

thank you again for your hlep


Open Powerpoint In Visual Basic
Hi there,

does someone know how to open powerpoint on no matter what microsoft operating system, or where powerpoint is installed?

There has to be a link in a registry somewhere? Isn't there a registry?

Would be very grateful for some help!


Can I Open An .exe Program With Visual Basic 6....
I'm real green to this developement stuff, but my question is, is it possible to open an .exe program with Visual basic or some other application so I can use it as an example for the application I'm creating. Or if I lost all my project files how would I be able to open my .exe application for futher developement, thanks

How To Open Screensaver Using Visual Basic
hi sir,

       im the one of all your subscribers. i send this email because i want to know how open screensaver using visual basic. Your sites is very good to all beginner's to know the new codes of other program languange. i hope you will help about my problem.

                                                                                     odelonCode:how to shutdown computerCode:how to open screen saver using visual basic


How To Open Autocad 2002 With Visual Basic 6.0
I use the below code given by the Autocad 2002 Help Developer documentation but it does not work. Beside that, do i need to open something else, press which icon or any other ways for it to work? My project requires me to use only this way to continue my project. For addition coding, please tell me which line to add. Thanks!

Sub Ch2_ConnectToAcad()
Dim acadApp As AcadApplication
Dim acadDoc as AcadDocument
On Error Resume Next

Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
MsgBox "Now running " + acadApp.Name + _
" version " + acadApp.Version
End Sub

How To Open A File From Withing Visual Basic

One of the tables in my SQL database has a field that holds file paths. My Visual Basic application is supposed to open these files with the click of a button (easier said than done). Instead of using a Web or OLE control, I would like to open the file in a separate window; for example, when selecting the file "Test.doc", and clicking the button, Microsoft Word is supposed to pop up displaying that file. The "Shell" function does that, but looks like I first have to figure out what type of application the file belongs to (by its extension), before I can call it, since it can only open executable files.
I was wondering if there is another function out there that would do the whole job for me (I know... I am so lazy, but my application is getting so complex that I would like to make the most out of any reusable code out there).



Open An Excel Workbook From Visual Basic
Hi all,

How can I open an excel workbook from visual basic 6.0?


Open Autocad 2007 From Visual Basic
Hi. I have the following code:

Dim objAcadApp As AcadApplication
On Error Resume Next
Set objAcadApp = GetObject(, "AutoCAD.Application")
Set objAcadApp = CreateObject("AutoCAD.Application")
objAcadApp.Visible = True
objAcadApp.Documents.Open txtFileToCheck.Text

the problem is that the AutoCad application is lunched in task manager but the file from txtFileToCheck.Text will not open. This code sequence works fine with AutoCad 2002. Could someone help me? Thank you!

Copyright © 2005-08, All rights reserved