vba

VBA - Calling a function which accepts parent object as variable

Is it possible to create a function which accepts it's parent object as a variable? I suppose the simplest way to illustrate what I'm talking about is to provide an example: Module 1 Code: Function IsProduct() as Boolean IsProduct = (vartype(Parent.Value) <> vbEmpty) End Function ' "Parent" in this case would be a Range ' Module...

How can I add a button to an Access report to export it to Excel / PDF?

How can I add a button to a Microsoft Access report to export it to Excel / PDF? ...

how to extract characters from a Korean string in VBA

Need to extract the initial character from a Korean word in MS-Excel and MS-Access. When I use Left("한글",1) it will return the first syllable i.e 한, what I need is the initial character i.e ㅎ . Is there a function to do this? or at least an idiom? If you know how to get the Unicode value from the String I'd be able to work it out from...

vba - scan documents for macro and replace macro text?

Hi, I'm presented with a puzzle. Where I work there are a huge amount of Word templates which all contains an autonew eventhandle which contains some errors. And this error lies within all templates. And I was wondering if there might be a way of scanning a directory for templates which contains this macro and change the macro code sligh...

How to save VBA variable in database?

I have a form in Access 2007. In the form is a browse-file button. From the file-picker dialog the files name is saved in a VBA variable. And now to the question, how do I save the file name stored in the VBA-variable in the database? The database has only one table. Hope you can solve this, if not all information you need is provided,...

How to import Microsoft Office constants (msoTrue, ppLayoutText...) into LotusScript?

I am trying to programmatically make a PowerPoint presentation from the contents of a Lotus Notes document. This is relatively straight-forward using CreateObject("Powerpoint.Application") but I fail to find a way to access the various constants that are used in VBA. One solution is of course to hard-code the (ten or so) values into my...

How to extract filename from path in vba?

How to extract the filename "myfile.pdf" from "C:\Documents\myfile.pdf" in vba? ...

How do I assign a value to a property where the property name is supplied at runtime in VBA?

I'm trying to create a worksheet that creates a list of values that will be used to initialize the values of an instantiated class. For example, I might have the following in my initialization worksheet: Property Name Value StartingCol A StartingRow 11 I'd then create a class that would pars...

How can I evaluate a string into an object in VBA?

In my previous question, How do I assign a value to a property where the property name is supplied at runtime in VBA?, I learned to use CallByName to set a property in a class at run time. This time, however, I'm trying to figure out how to get an object at run time from a string. For example, let's say I have a string with the followi...

Does VBA keep a cache of past code changes?

I created a smallish application in VBA for autocad (.dvb file). It has a form and a bunch of modules. I originally wrote some code in a module that contained and IP address (10.0.0.16). Later on I replaced the IP address with the actual netbios name (MyServer). In doing some maintenance I had searched the folder containing this file w...

VBA to C# Value Statement

In VBA I indicate: If Option1.Value Then TextTo= "Meters" End If How can I use (.Value) in C#? ...

What is the VBA equivalent for using Command.Prepare in ADO.NET

Is there a way to use Command.Prepare, and Command.ExecuteNonQuery in VBA? The section entitled "Consider Using Command.Prepare" in the following article on ADO.NET describes objects and methods that are similar to ADODB properties and methods and I am wondering if there is an equivalent for VBA. ADODB has .Command, .Prepared, and .Par...

VB/VBA Variable Declaration Coding Standard - White Space

What is the significance of declaring variables in VB/VBA like so: Private m_sName As String Private m_lAge As Long As opposed to; Private m_sName As String Private m_lAge As Long I am working on a project which up to now uses the latter, and has done since long before I joined the project. Two new developers have...

Question about vba in PPT(Microsoft PowerPoint )

I want display a progress bar when showing ppt. I write code like this: Public WithEvents App As Application Private Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow) Dim Showpos As Integer Showpos = Wn.View.CurrentShowPosition Dim PageCount As Integer PageCount = Application.ActivePresentation.Slides.Count Sli...

Iterating Through a Class in Excel VBA

I have created a class module for an entity called Terminal. I have a method that populates this class by going through 175 seperate worksheets and pulling the correct data from specific cells. This process is very quick (about 2 seconds), however when I try to write this data back out to a new worksheet, it is taking much longer (45 s...

Word VBA: How to determine a document newly created and modified?

Hi, Does anybody know in Word VBA how to determine: A document is newly created; A document is modified by the user? I found the Document.Saved property, but it does not help in my case. Thank you so much! ...

Excel macro run from the web?

I have been handed a critical macro that takes an old school file full of invoices which thankfully is quite consistent. The macro reads this file, moves the data around to make it consistant and then generates a three tab speadsheet which is pretty much three CSV's. It then generates off these three CSV's another speadsheet which has ...

When do I need to dispose objects in VBA

While looking at this code (most of which has been removed for simplification of this question), I started to wonder if I need to dispose of the collection or class that I used. Option Explicit Private terminals As Collection Sub BuildTerminalSummary() Dim terminal As clsTerminal Call LoadTerminals For Each terminal in termin...

VBA: How do I find a cell containing a substring in a given range?

Say I have a range of data from A1:Y55 containg data like "123 UID" I am looking for a unique substring (in this case, the UID) in that range, how do I do this? ...

Excel VBA pastelink run-time error 1004: Application-defined or object-defined error.

I am trying to create a link from a cell on one sheet to a cell on the other sheet, but when I run it I get this runtime error: Application-defined or object-defined error. Here is the code: Worksheets(sheetFrom).Cells(fromRow, fromCol).Copy Worksheets(sheetTo).Cells(toRow, toCol).Select ActiveSheet.Paste Link:=True I am checking th...