vba

How to get Access 2007 to run VBA subroutines when scrolling through records in a form

I have a series of "on Change" Enabled/Disabled subroutines in the VBA for a form. When scrolling through the form to view records however, only the main routine runs--the subroutines don't. As a result, questions appear disbaled that have responses displayed. How do I get the subroutines to run when a record is viewed/changed? ...

Excel - Red Cross where a drop down list should be

Hello, anyone shed any light as to why this might be happening for one user but not another. Excel 2003 Macro security is set to low; spreadsheet is not read only. Everywhere where there is supposed to be a drop down list, instead of that there is a box with a red cross in it. Kind Regards, Jim ...

Server moved, now MS Excel 2003 queries won't work

We use MS Query to retrieve data from various databases to create management metrics (i.e. within Excel, go to Data...Import External Data...New Database Query). The SQL query and parameters (mostly conn string) are automatically stored by Excel within the spreadsheet. However, we recently moved one of our databases to a new server. ...

Finding what is different from VB(MSVisualStudio 2005) and VBA(Excel)

I found code online for something I wanted to do. As usual, I fired it up in Visual Studio and it works no problem. The problem occurs in that, when I try to port it over to Excel, it ceases to work. As I understand, VBA is a watered down version of VB. (Based on reading this article: http://stackoverflow.com/questions/993300/differenc...

Print to POS Display Unit

I have an Epson Display Unit (for the Point of Sale), and have it set up as a printer. I can only get it to print what I want when I go to Printer Properties > Fonts (there is a test input box). However printing from an app such as notepad yields no results. I'm trying to get it to work with the p.o.s. app I made in Excel. I found a ...

Does the ReDim statement intialise String Arrays with empty strings?

Given the following statements in VBA: Assume that val = 4 and Option Base 0 Dim dataStr() As String ReDim dataStr(val) Will the ReDim statement intialise the String array dataStr to 5 empty string elements(0 to 4). What exactly will be the contents of the Array after the execution of the ReDim statement. ...

How do I know when a file has been modified in a VBA Macro?

Is there a way to watch a file in VBA (which is essentially VB6), so that I know when the file has been modified? -- similar to this only I don't want to know when a file is unused, just when its modified. The answers I've found have recommended using "FileSystemWatcher" and the Win32 API "FindFirstChangeNotification". I can't figure ou...

Unlock/lock form objects with vba

Hello, I have an excel worksheet with 2 comboboxes, and 3 scrollbars. I want to protect all the sheet except this form objects (and one cell). When i try to protect the sheet, i can't use the scrollbars and comboboxes. How can i unlock them, keepin the protection for the rest of the sheet with vba ? I tried to unlock the cells linked to...

How do I Merge two Arrays in VBA?

Given Dim arr1 As Variant Dim arr2 As Variant Dim arr3 As Variant arr1 = Array("A", 1, "B", 2) arr2 = Array("C", 3, "D", 4) What kind of operations can I do on arr1 and arr2 and store result in arr3 such that: arr3 = ("A", "C", 1, 3, "B", "D", 2, 4) ...

Alternate use of the Array() function in VBA?

We generally use the array function is VBA as : Dim A As Variant A = Array("B", 1) This will give me the first element in A as "B" and second element as 1 However I want to decide the contents of A at run-time so is it possible for me to do something like Dim str As String Dim A As Variant str = "name, Sam" A = Array(str) When I...

how to detect whether VBA excel found something?

i am using this to in a macro to find stuff in my sheet: Selection.Find(What:=email, After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False, SearchFormat:=False).Activate how can i tell whether or not it found something? ...

vba word 2007 - protect document but enable toolbars

I have a document with sections that are protected and unprotected. With Word 2003 the sections that were unprotected had formatting enabled - specifically the bullets and numbering. Now with Word 2007, even though the same sections are unprotected, the bulleting and numbering is disabled. Is there anyway to enable this? I tried playing...

Merge like dates in MS Access

I am a pilot who flies multiple legs in a day. The software I use to log flights spits out a csv file and lists every leg separately. I import the csv file into table 1 in ms access. I would like to merge all flights from the same day into one record on a new table. My problem is combining the route and adding the time. Table 1 ...

Hide Parent Page Hyperlink Excel

I would like to hide the current page that the user is looking at when they click a hyperlink within excel that takes them to a different worksheet within the same workbook. I tried using the following code Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) On Error GoTo Cleanup ActiveSheet.Visible = False Applicati...

excel vba: how to loop through a subset of worksheets

I know how to loop through all the worksheets in a workbook, and how to exit once I reach an 'end-flag' worksheet: For Each ThisWorkSheet In Worksheets If ThisWorkSheet.Name = "FlagEnd" Then Exit For MsgBox "This worksheet name is: " & ThisWorkSheet.Name Next However I cannot get the loop to begin on a 'start-flag' worksheet (or...

How Do I Find The Cells With Contiguous Data In A Row In Excel VBA?

Given the Image... If I know that there is some data starting at Range("B3"). How can I find the cells with contiguous data that is till cell E3? Since F3 is blank G3 onwards should not be considered. The result could either be a range object (B3:E3) or count of cells( 4 in this case). By setting B3 as the Active cell and doing.. R...

Converting plain text in SQL to hyperlink in Access

Hello, I've just started a new job my first since leaving University and as part of this my first task is to convert a wholly Access 2003 database to an Access front-end, SQL back-end. The Access database consists of a series of front end forms to add or review staff data, as part of this there is hyperlinks pointing to a photograph of ...

selected index of a vba combobox

The title is enough i think. I used to code VBA 2 years ago and I suppose I have forgotten lot of stuff. How Do I access the SelectedIndex of a activex combobox object in Excel? I need an integer :( ...

set NewStyle doesn't work

Using VBA in MS Project 2003 and working with a Word Document I try to create a new style using Function CreateStyleHeadingTask(NameStyle As String) As Style Set CreateStyleHeadingTask = Nothing If Not wdDoc Is Nothing Then With wdDoc Set CreateStyleHeadingTask = .Styles.Add(Name:=NameStyle, Type:=wdSt...

Merging records with consecutive dates

I have the following problem in a Database using Access 2007 as front end and SQL2005 as back-end. In Table A I have the following data structure Table A ID Date Supplier_ID 1 10/22/2009 1 2 10/23/2009 1 3 10/24/2009 2 4 10/25/2009 2 5 ...