vba

VBA global variables

I have the following code for handling userforms on my spreadsheet VBA macros: Option Explicit Public saved_vocab As String Public saved_num As String Public saved_def As String Public saved_ex As String Private Sub Save_Click() Dim low As Integer Dim high As Integer Dim selected As Integer low = 1 high = Cells(1, ...

vba more realistic random number generator

I know I can use a quasi-random number generation function/variable called Rnd. However, I've noticed that whenever I used Rnd in my userform, this sequence of numbers always show up: first iteration: 0.705547511577606 second iteration: 0.533424019813538 ... As a result, b/c the sequence of numbers showing up are the same every time wh...

Questions about splitting Access Database into Front/Back-end

Okay so I split my access database, and now I have a backend: If I started a brand new table, a brand new query, and a brand form for a different purpose within the db_be.mdb would it appear in the connect "front end" db as I saved it in the backend, or do I have to import it up? If I do have to import the above, the how do I make th...

Can a worksheet object be declared globally in Excel VBA?

I'm refactoring a number of modules in an Excel 2003 workbook and the same set of worksheets are declared in each procedure in each module; I'd like to just declare them once globally. I can set the worksheet name as a literal, e.g.: Public Const xlwkGSModel = "gs_model" As String And then in the procedure use: ...ActiveWorkbook.Wor...

Inserting Japanese characters to Sybase db from Excel

I can see the Japanese test in the excel cells. I've built the insert query using ADO. It does the insert in the DB, but Japanese characters are simply represented as "????" Any help would be appreciated. ...

How can I make a network connection with Visual Basic from Microsoft Access?

We have a Visual Basic application inside of Microsoft Access and we need to make a network connection. With VB6, there was a handy little control called WinSock that made this possible, but I can't find anything similar for the stripped down VB version that exists inside of Microsoft Access. Any ideas? Since I'm not getting any answers...

Load image file to clipboard

I'm looking to get an image of a Visio page into the clipboard using VBA. I can export an image of the page using the .Export method of the Page object in question. But is there a way to load an image file to the clipboard within VBA? Or should I just use something like VB6 and make a little command line tool that just loads a jpg or b...

How to change column names from VBA

I am creating an Excel spreadsheet in Access vba code. I need to change the column names from A, B, C, etc to a meaningful name. I have looked high and low but cannot find a way. ...

Data extraction with Excel

I monthly receive 100+ excel spreadsheet from wich i take a fixed range and paste in other spreadsheet to make a report. Im trying to write a vba script to iterate my excel files and copy the range in one spreadsheet, but i havent been able to do it. Is there an easy way to do this? ...

Where to cancel Application.OnTime in VBA

Using VBA in Excel 2003, I'm trying to cancel an Application.OnTime event using the following code: Application.OnTime EarliestTime:=varNextRunTime, Procedure:="SomeMethod", Schedule:=False where varNextRunTime is a global variable containing the next time it is due to run. This code runs in the Workbook_BeforeClose event handler so ...

Excel VBE inconsistent exports

Hi, I am exporting .bas files from an .xls file as outlined here: Exporting A VBComponent Code Module To A Text File to check them in into an SVN repo. I am encountering the following issue which causes a change on the files that is actually not real (or at least not relevant). statements like these get reformatted: rngTenors.Cells(i,...

MS Access 2003 - Creating a Dashboard - Return Values to a form?

So this is something that I have never tried, but I think I want to create a Metrics Dashboard in my MS Access database. So I think the first question that I need to ask is how can I return a value to a form? If I ave aggregate queries that are top 10 total sales, how can I specify not only the query that I want the top result to come f...

Visual Basic _ Question about findings the right study material?

Hey does anyone know of a great book/CD-ROM, etc for learn some novice to advanced Visual Basic study. I think I have about graduated the beginner stage. The main thing I need to do with Visual Basic is use it in conjunction with Office applications (2003 to be precise). Mostly MS Access, Excel and PowerPoint. But I want to learn more, I...

How to "order by" a column and "Include Column Name with query"?

Hi, I am trying to run a sql query in excel and I want to : 1. order the query result by my column "Stationname" 2. include the column names with the query Right now it is returning all the columns without the column name, and the end users do not know what it is. Could someone please help? I am stuck! Below is my current code: ...

VBA in Excel: Global Constants File

I'm working on some VBA scripts for an Excel worksheet, and I've created a module that contains a whole listing of mostly strings that store the name of each of my database fields. That way, if anyone modifies the database, they can update the VBA variable in the module, and then all my scripts, which reference the global variable instea...

What are the best tools for optimizing queries in VBA and why?

I'm fairly new to programming and I was wondering; What are the best ways to time and optimize my code? The code I'm currently wanting to time is a series of queries in VBA for MS-Access, but I would also like to time code in VB.NET and ASP.NET as well. So to reiterate, what is the best way to time code and optimize it for each languag...

How can I switch an Access database between shared and exclusive mode?

I'm working on a program that needs to edit some objects in an Access database. It also runs a subprogram (long story) that tries to access the underlying JET database while Access still has it open via ODBC. The problem is that as soon as I start editing Form objects using VBA - for example, using Application.LoadFromText - Access cha...

Input mask for partial date without year in vba

I have the below input mask which take in the date format: 21/10/98 00/00/00;0;_ But i need to be in the below format : 21/10 (without year) This syntax of input mask shown below 00/00;0;_ is not giving the right answer. Please help More clarification: If we right click on the text box of vba form and take the input mask pro...

Call UserForm on Save

Hi, How do I go about calling a userform in VBA when user clicks on the Save button in MS Word? ...

Read Only Custom Properties

I managed to add custom properties (metadata) for MS Word from VBA, but how do I make it read only so that it cannot be changed easily? ...