Visual Basic Code - Open Local PDF At Specific Anchor From Excel?

Aug 8, 2012

I want to create a series of hyperlinks in excel to pdf's stored on a local drive/CD as a kind of database. This much I can do with a nifty bit of code I saw someone put up here as follows;

Sub Run_Local_PDF()
MyPath = "C:Program FilesAdobeReader 9.0ReaderAcroRd32.exe"
myFile = "C:Documents and SettingsmynameDesktoppdffilename.pdf"
Shell MyPath & " " & myFile, vbNormalFocus
End Sub

Which works great and is sitting snug in a module. However, the document I am linking to has various anchors in it which exisit as sectionheaders. One of which is "Contents".

Is there a quick way I can alter my exisitng VB code to open at one of these anchors?

View 2 Replies


ADVERTISEMENT

Using VBA Code In Visual Basic: Develop A Stand Alone Program In Visual Basic

Jun 3, 2006

I would like to do is develop a stand alone program in Visual Basic ( not in Excel VBA) to update the price file in our Portfolio system automatically using the downloaded Excel format file csv extention file from the BigCharts. But before that, I need to export the *.pri file from our Portfolio system in to Excel which still saves as *.pri extention. Then once it updates, I import the updated *.pri file back in our Portfolio program. I understand that the Excel VBA code can be incorporated in Visual Basic code provided there is an object declaration for Excel file (In this case eventhough the both files are in Excel format, they don't have xls extention). how to use external files and Excel VBA code in Visual Basic?

Below is the code that I currently have in Visual Basic. What I'm trying to accomplish is using the ticker (eg. msft) as a keyword search to look up in the price file. If found , the price of that ticker from the test.csv file will be copied in to the price file which is test.pri. I haven't ran it yet.

Sub UpdatePrice(BigChartPath As String, BigChartName As String, AxysPricePath As String, AxysPriceName As String)
'Below are Excel VBA codes
'Uses the test.csv to look up tickers in test.pri and update the price in it
Dim PriceFile As Workbook, BigChartFile As Workbook
Dim PriceFileSheet As Worksheet, BigChartSheet As Worksheet
Dim MaxRows As Long
Dim PriceFileRow As Long
Dim BigChartRow As Long
Dim BigChartFound As Boolean
Call CheckBookOpen(BigChartPath & BigChartName)
Call CheckBookOpen(AxysPricePath & AxysPriceName)
Set BigChartFile = Workbooks(BigChartName) 'Big Chart website imported CSV file saved as test.csv...............

View 5 Replies View Related

Open Workbook With Visual Basic (VB)

Jul 10, 2007

I am trying to open a closed workbook, auto update and save. Here is the code i have so far:

Dim xlBook As Excel.Workbook

Try

xlBook.Add()
xlBook.Open(FileName:="C:Old Tanglewood Numbers.xls", UpdateLinks:=1)

Now, the xlBook.Add() line is something I just added. I am not sure if it works but i dont think it does. Everytime i try to use Workbooks.Open it tells me that i need to decalre Workbooks, which i thought i did with xlBook. Anyway, I cant get it to work, something is throwing it out of whack.

View 9 Replies View Related

Macro Not Working While Visual Basic Is Open?

May 1, 2013

I have been running a macro on a continuous loop to collect data for months. Yesterday I added something small to the macro and now it does not select cells. I tried closing excel, opening a new page and have a simple macro

Sub Please_Work ()
Range('A4').Select
End Sub

If I have VBA open and step through it (F8), it does NOT work. If I run the sub (play button), it does NOT work. If I close VBA, and run the macro it DOES work.

View 9 Replies View Related

Macro Has Errors If Visual Basic Editor Is Not Open

Nov 12, 2009

I've been helping another user create a workbook that dynamically adds, renames and deletes worksheets from a "Main Sheet".

I have got the whole thing figured out and running to satisfaction, except...

The macro runs fine if the Visual Basic Editor is open. If the editor is closed while the macro is run, I get "Runtime Error '9': Subscript out of range"

Any ideas what could be casing this? The errors occur when attempting to add sheets.

View 2 Replies View Related

Visual Basic Editor Font Settings For A Specific Workbook Only

Aug 4, 2008

I only want to change some Visual Basic Editor (VBE) font settings on the active workbook, but whenever I do so within the Editor tab of the Options dialog it changes the VBE font settings for all workbooks.

Is it possible to change just the active workbook VBE font settings or do these settings reside in some *.ini file that once changed, globally changes the setting(s).

View 3 Replies View Related

Running Userform From Visual Basic Editor From A Vb Code

Oct 10, 2008

how to run a userform with a macro that opens the visual basic editor and runs the userform1 in it; rather than using userform1.show.

View 9 Replies View Related

Display Line Numbers Against The Code In The Visual Basic Editor?

Feb 26, 2008

Is there any way I can display line numbers against the code in the Visual Basic Editor?

Or can I see in the current line number in the status bar?

or GoTo Line number?

View 13 Replies View Related

Difference Between VBA Excel 2003 And Visual Basic 6.0?

May 3, 2012

whats the difference between vba excel 2003 and visual basic 6.0 I don't understand, if it is the same or complete different.

View 3 Replies View Related

Excel 2010 :: Checking If (Trust Access To Visual Basic Project) Ticked

Sep 17, 2012

I have a macro that seems to work okay for older versions of Excel - I use Office XP (2002) tell me if this will work for newer versions (2007 / 2010)?

KB1017 - Trust access to VBA project

Code:
Function VBATrusted() As Boolean
On Error Resume Next
VBATrusted = (Application.VBE.VBProjects.Count) > 0
Exit Function
End Function
Private Sub Workbook_Open()
If Not VBATrustedAccess() Then

[code]....

I was thinking that i should probably have

VBATrusted = -1

as the third line so that it is negative unless the tick is there. No way of checking older versions right now though.

View 3 Replies View Related

Macro To Only Show Rows That Contain Specific Text/Chinese Text Issue In Visual Basic ( 2007)

Jun 23, 2009

I want to create 3 command buttons (active X) on a worksheet to toggle between showing rows which only contain the below text in column L (range L9:L30) and showing all rows containg the options (However, I also have some blank rows in this range and i always want them to remain hidden.)

My text options are:

High ‚
Medium ՠҪ
Low ’á

The text arrives in the cells via a VLOOKUP

Is the chinese text a problem? i can't type it into VB.

I've been using the following macro to hide and unhide rows with a command button in the same sheet:

Private Sub CommandButton1_Click()
Toggle_Hide_Unhide
End Sub

Sub Toggle_Hide_Unhide()
Dim rngCell As Range
Dim TakeAction As Boolean

If ActiveSheet.CommandButton1.Caption = "Hide" Then
TakeAction = True
ActiveSheet.CommandButton1.Caption = "UnHide"
Else
TakeAction = False
ActiveSheet.CommandButton1.Caption = "Hide"
End If

For Each rngCell In ActiveSheet.Range("I9:I30")
With rngCell
If .Value = 2 Then .EntireRow.Hidden = TakeAction
End With
Next rngCell
End Sub

View 9 Replies View Related

2007 - Visual Basic

Jan 23, 2008

how I can get to the visual basic toolbar in excel 07. In previous versions there was a visual basic toolbar and it allowed you to add buttons, ect. Where is this in 2007?

View 9 Replies View Related

Visual Basic And Images

May 6, 2006

Is there a code you can type in to VBA to allow a picture in a spreadsheet to change when a parameter is specified. For example i have a picture of a timber beam i drew in excel. and i wondered if i could set it up so that when the user inputs the length of beam they are using, the diagram alters to show the length specified.

View 2 Replies View Related

Visual Basic To Access Web

Aug 4, 2007

My company "makes widgets". Each "type of widget" is associated in our internal database with a record locator (five alpha characters). Our company website can also use that record locator to pull up a webpage specifically dedicated to that widget. In addition to the webpage itself, the website also creates an expanded URL which contains additional information about that widget.

I'd like my macro to take a list of record locators, open up the company website related to each specific widget, pull back the expanded URL, and do some text management with the URL to populate other parts of the spreadsheet.

For example, if my record locator is "ABCDE", my macro would go to the website, "http://www.widgets.com/ABCDE". The site then redirects to an expanded URL: "http://www.widgets.com/whole-bunch-of-data-about-the-ABCDE-widget". I'd hope to write a macro which pulls back the expanded URL and does some magic with the "whole bunch of data" part. I've been told that the MSHTML library would be useful for a project of this type. I've been able to connect my spreadsheet to that library, but then I'm not sure what to do with it.

View 4 Replies View Related

Tap Into Access Visual Basic Function

Sep 9, 2008

Is it possible to have Excel tap into an Access database and call up a function?

I have an Excel sub that looks like so

View 15 Replies View Related

Lost Visual Basic Project

Oct 24, 2008

Have a project going and have had a disturbing trend develop. I'm working in Excel 2003. Upon opening the file and enabling macros, I started receiving File/Path errors, at which point it would shut down the application. When opened, I have a splash that would come up, but it wouldn't go to the next userform. At this point I would get the error message and the file would be closed. If I then reopened the file, disabled macros, saved under a different file name, and then reopened with macros enabled, everything worked fine, until I shut it down and then tried to reopen, at which point the same error would occur.

Lately I have simply been getting the Microsoft Excel dialogue box telling me an unexpected error occurred and it had to be shut down. I'm at a loss for what is causing this. The last time this happened, when Excel recovered the file, it told me a repair had been done, and the repair was to basically delete all of the VBA code from the file.

View 14 Replies View Related

Visual Basic Compiler - Odd Performance

Nov 23, 2009

I am encountering a situation wherein each line of VBA code is essentially compiled as I type on that line, instead of when I move to a different line. For example, if the code I entered is incorrect, the compiler waits about half a second and then turns it red. Also, if I enter a space, it deletes it immediately.

View 4 Replies View Related

Changed Cursor While Using Visual Basic

Jan 6, 2010

I'm sure this is something I've accidently pressed while using VB. My text cursor has changed from the usual 'I' shape to a black box shape. Now instead of adding text where I'm typing it now types over previous work. Is there an easy fix for this.

View 2 Replies View Related

How To Pass Variable Value In Visual Basic

Sep 26, 2013

How do you pass a variable value in Visual Basic?

I have a variable called LastRow
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

Would like to pass the value in my Do While loop

Option Explicit
Sub IncValue()

Dim MyCell As Range
Dim LastRow As Long

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Do While MyCell

View 2 Replies View Related

Microsoft Visual Basic Error 400

May 2, 2007

My code here...

Sub ClearSheet()
Worksheets("Summary").Activate

If Range("CustInfo") = False Then
Range("ICompany, IPhone, IFax, IContact, ICell, IEmail, IAddress, IPOBox, ICity, IState, IZip").Select
Selection.ClearContents
Else
Range("IJobDescription").Select
Selection.ClearContents
End If

For I = 1 To 5
Range("Qty" & I).Select
Selection.ClearContents
Next
End Sub

keeps giving me an error 400. I have reinstalled xl just to see if it was related toan error I recieved earlier relating to VBE6.dll. This still works in another workbook but it doesn't work in this one. All I did was change the Range names and cleaned it up a bit.

View 9 Replies View Related

Visual Basic Opens Automatically

Oct 19, 2009

I have a VB problem, and it's driving me nuts.

Whenever I run a macro on excel the Microsoft VB editor opens and shows me what the macro looks like. It also runs the macro.
Now, I would very much like it to keep running macros, but I really don't need to see my code every time. It gets really annoying, and I need to run about 40 or 50 different macros on one sheet. How can I make it go away?

PS! It's Excel 2007 for students, Norwegian version.

View 9 Replies View Related

Visual Basic Form Asc Library

Apr 28, 2007

I have four columns in my worksheet. In column C, I need to find the no. of times word "Alarm" is occuring. Further, with each "Alarm" entry in col C, there is a alarm type given in column D. I need to find the no. of alarms for each type and then display a bar chart for the alarm type vs. frequency of its occurence.

View 4 Replies View Related

Entering Codes In Visual Basic

Jun 20, 2007

Do you enter codes on your own or do you just click on the commands in the top right scrollbar in design window at most of the time?

I'm teaching myself Excel VB but I'd like to know if most of you just click on the command for codes as you go along or you can enter the codes yourself without the help of the command buttons

View 7 Replies View Related

Visual Basic - Not Allowing Cell Entry

Aug 20, 2008

I have a cell that I do no want anyone to enter any information into unless a previous cell has "U" inside of it.

Okay so so I have a column of cells named "Fringe Benefit Type" you can choose different letters to corropand to different types. Now I have set the letter "U" to be the one I want and that works. Now the next cell is called "Hire Season". Now (stay with me here) IF "Fringe Benefit Type" is equal to "U", I don't want the user to be able to enter anything into "Hire Season".

I am using the visual basic thing, which already has some code, but I am not understanding it too well.

View 14 Replies View Related

Visual Basic Add Text Boxes Without Button

Nov 22, 2011

This is basic but can't seem to work it out.

I have 2 text boxes and 1 label. I want -to add the numbers together I enter into the text boxes without using a button to start the sub.

Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

View 1 Replies View Related

Send Email Through Macro Visual Basic?

Sep 21, 2013

macro visual basic and trying to do a simple report wherein i can send an email auto matically.

View 2 Replies View Related

Amending Sheet Visibility In Visual Basic?

Jan 28, 2014

Error message: Unable to set the Visible property of the Worksheet class

View 1 Replies View Related

Visual Basic Auto Filter Macro

Nov 19, 2007

I have a excel file that was created by someone else 7 years ago - I still want the formulas that were created but I have updated the information on the spreadsheet and now the macro will not work

Sub DataSort01()
'
' DataSort01 Macro
' Macro recorded 11/18/00 by Terry Schiesser
'
' Keyboard Shortcut: Ctrl+t
'
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:=">0", Operator:=xlAnd
End Sub

when I do the ctrl+t it wants to debug I select the debug option and then it goes to the screen above but the "Selection.Autofilter" is highlighted.

View 9 Replies View Related

Microsoft Visual Basic :: Error In Loading DLL

Dec 22, 2008

i have a macro he was working good but now i got a box labeled "Microsoft Visual Basic" saying "Error in loading DLL" and the macro won't open. I can't figure out what I'm missing.

View 9 Replies View Related

If Statement - Visual Basic For An Input Form

Dec 10, 2009

I am creating a user input form where the user can enter data about what they have eaten on a certain day. I am using radio buttons, so when the radio button has been clicked, it automatically puts something into cell A1. What has been put into cell A1 will then be used to say what is in the combo box named Cbo_FoodItem. I have used the following
With Me.Cbo_FoodItem
If Worksheet("na").Range("A1") = "carbs" Then
Cbo_FoodItem.List = Worksheet("foodtable").Range("B2:B215").Value
End If
End With

However, when i try to test it, i get an error which then highlights the "Worksheet" after IF and says "Sub or Function not defined".
Obviously there is something wrong with the formulae, however i cannot work it out. Please help.
I've only just started using visual basic, but i am starting to get the gist of it.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved