vba

Read Macros from External File quickly

Here is my code, For Each pj In wdApp.Application.VBE.VBProjects x = pj.FileName y = pj.Protection If x <> "" Then If y <> "1" Then For Each vbcomp In pj.VBComponents For i = 1 To vbcomp.CodeModule.CountOfLines newMacro = vbcomp.CodeModule.ProcOfLine(Lin...

Program to automate reset of password on Windows Server

Program to automate reset of password on Windows Server I would like to be able to automate the reset of user password (and possibly change password to a default value) based on an email received from a user within the company For this I would require a program to change password account and a way to trigger a program based on an ema...

How to erase or reload strokes to an InkPicture in VBA for Ms Access?

I would like to display strokes that I have saved previously on an inkPicture Object in Ms Access (it is on a form via ActiveX). The strokes are saved in a table as an ole-object in the field 'Strokes'. Now, doing it once is easy enough (one line of code), I can use this snippet without any problem : Public Sub loadInkImage(MyInkPic ...

forcing EDIT of access backend database

i have about 20 users who have their own access front end and write to a backend. i need to do an update to the backend, and every time i try to do it offhours, it seems that someone is still logged on because the file is locked! how do i get around this? i do tell the users to log off at the end of the day but a lot of them forget! is...

Http Post in Vba

I am trying to figure out how to make a POST in VBA. Ideally I'm looking for a simple working example that I can play with. This is what I have so far, but I'm not really sure what to do with it. Mostly what does the formdata look like. Function WinHTTPPostRequest(URL, formdata, Boundary) Dim http Set http = CreateObject("MSXML2.X...

Excel VSTO Late-binding deployment problem

I've got an Excel 2007 Workbook that uses mixed VSTO/VBA automation that I'm trying to deploy. Everything was working pretty well, but now I'm running into a stubborn issue with allowing my VBA code to make calls into the VSTO compiled code. I've set up my VBA and code-behind according to the walkthrough posted at http://msdn.microsoft...

Word VBA Range.Find object works incorrectly

I found an interesting thing: In word 2010, select some text, and run the following VBA code: public Sub Test() With Selection.Range.Find MsgBox .Execute(Selection.Range.text) MsgBox .Found End With End Sub Both the two message box say "False", but both should be "True". Why? Thanks a lot for your suggestion...

Dealing with excel files what can be used besides VBA?

I have been working on an excel file which will combine each of the excel files sent by the users. So I will have a user entry row per file. I started by using VBA. I thought that it would be the best, natural choice, though I did not know how to use it previously. At the moment I have come across problems that I have no idea how to so...

Insert bold text into Word using VBA

I wrote a little script that exports certain Excel cell values into Word. However, certain inserts need to be bold. And there doesn't seem to be an easy way to do this. This code loops through the records and adds them to the Word document Do While intRow < intTotalRows + 1 strTemp = " ;b;" e; " If st...

Building an XLA from Source Programmatically

I have a (version controlled) folder of exported components of a VBA addin (i.e. a lot of cls, frm, frx, bas and txt files). Can someone give me a build script (can be a VB script, or something more complicated) that takes the name of this folder and produces a (working) XLA? I know you can programatically modify XLA files (e.g. this q...

Loop through cell dependents

this expresses what I would like to do but obviously does not work. I think what I am trying to do is clear: Get a cell, get its dependencies count, and output all of them. Thanks in advance for any input Sub Extract() Dim i As Integer For i = 1 To Workbooks("myBook.xls").Worksheets(1).Cell...

Access - Report opens and then is hidden when opening form is closed

I am using Access 2003 and I have a form that collects some filtering criteria for the report. Once the criteria is entered the user clicks and "OK" button and the report is launched using the following VBA. DoCmd.OpenReport "ReportName", acViewPreview After the report is opened I issue the following command to close the form that col...

Maintaining modules/macros in Access.

Hey guys I've written a little module/macro that helps our inventory department, they will need to run the module/macro a few times every month. They receive the databases from out in the field these are exported from some 3rd party inventory tracking system we have. My question, is there any way to install this module/macro outside of ...

Populate a dropdown in word from column in excel and then on dropdown change populate textboxes with related field (VBA)

Hi, I have the following code in a word 2007 macro where I populate a dropdown with customer names from an excel spreadsheet Private Sub UserForm_Initialize() Dim i As Integer Dim cn As ADODB.Connection Dim rsT As New ADODB.Recordset Set cn = New ADODB.Connection With cn .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Data S...

File import with interface similar to Windows Explorer in Access 2007

I would like the user to import the files into my Access VBA, I wonder if I can make the interface to be a bit like Windows Explorer: With the window split into 2 halves, user can highlight the directory on the left half, and then the right half will show the files inside (even better if it can filter the file with specific extension), ...

How to deal with single quote in Word VBA SQL query?

Hi, I get a customer name from dropdown and use that value to query an excel spreadsheet, however, the name can contain a single quote (example: Adam's Meat). This breaks my application and how do I make a query with a variable that contains a single quote? Private Sub cboCompany_Change() Dim customerName As String ...

vba how to update fields

I would like to update a Word field from a VBA macro. The Word Doucument is wrdDoc in the code below. When I run the code I get a Type mismatch error on retrieving the properties. If anyone can help I'd be really grateful. Dim objCustomProperties As CustomProperties Set objCustomProperties = wrdDoc.CustomDocumentProperties For i = 1 To...

Access - VBA Code problem Date- problem

Hey all, have managed to finish the database; but have run into a problem with something I did in the beginning. Basically, the calculations in the database are done using VBA code. Now I've run into a problem where instead of slecting just the last two years worth of data, it is now slecting and using data from more than two years ago. ...

Managing user-defined types across various modules

What is the best way to manage common user-defined types across VBA modules? I use the same user-defined types in different modules. For example, I often need to represent (x,y) points, so I end up having this Type in different modules: Type XYpointType x As Double y As Double End Type I pass arguments of type XYpointType to...

How to stop VBA code running?

Hi, guys. Say I have a button embedded into my spreadsheet that launches some VBA function. Private Sub CommandButton1_Click() SomeVBASub End Sub Private Sub SomeVBASub DoStuff DoAnotherStuff AndFinallyDothis End Sub I'd like to have an opportunity to have some sort of a "cancel" button that would stop SomeVBASub ex...