vba

How to deploy C# code and VBA scripts in one VSTO Word addin

Underlying problem I was trying to solve is to apply custom key bindings for internal VSTO Word addin methods (develiped in C#): Globals.ThisAddIn.Application.KeyBindings.Add( Word.WdKeyCategory.wdKeyCategoryCommand, "MyMethodName", myKey, ref _missing, ref _missing); Well, the problem is that this code alw...

Automate Text Import in Excel 2007

I'm trying to write an Excel macro using VBA to automate importing CSV text into a spreadsheet but I've never done it before. I need to make sure that the Text Import Wizard that comes up is run through the same way each time. The steps I need to take are: Open a file, using an open file dialog Set type to Delimited Set Delimiter to ...

How to plug a range object into a formula

I want to plug a range object into a formula. An example should look roughly like this: Dim x As Range Set x = Range(Cells(1, 1), Cells(2, 1)) Range("C1").Formula = "=SUM(" & x & ")" The result should be "=SUM(A1:A2)" in cell C1. The point is to plug the the range object into a formula. I used SUM as an example, the real formula is...

Can I use / access the app.config from .net code, when called via COM

I have an existing set of .net libraries that I wish to call from Excel VBA (that part is working fine). These libraries rely on settings in the app.config. I know I can enter these settings in a excel.exe.config file (placed in the same directory as the excel.exe), but this doesn't really seem like a very manageable solution to me, as I...

How can I execute a shell command using VBA?

Hello, I want to execute the shell command: "C:\Temp\gc.exe 1" but I want to do it using Visual Basic for Applications. How can I do it? Thanks in advance! ...

Object does not get created on Virtual PC

I have set up a virtual PC (XP SP3) for executing automation developed in VBA. This automation creates an object of few Dlls developed in C# and VB.Net. But when I execute the automation using this VPC machine; the required objects does not get created and automation fails. Please let me know what could be the reasons for the same and ho...

Microsoft Access - Override Maximum Font Size?

Have a Access 2007 database which needs to have a report that prints out some really big numbers (for some signage). Currently in Excel the template uses a 400 point font size. When trying to change the font size in Access the following error message appears: The setting of the FontSize property must be from 1 through 127 I tried...

When using devenv /command to execute a command or macro can you make the process return an error code or message?

Not going into detail on why I want to do this, I need to execute a macro inside Visual Studio as part of our msbuild script. The macro performs some actions in the IDE and then calls Application.Quit() to close the IDE. Do you know if there is a way to make devenv.exe return some error code or anything really that could let msbuild kno...

How to create a Sub in VBA that is executed when its correspondent Add-In is loaded?

I have a subroutine in VBA that is executed when we open a PowerPoint presentation but I want to execute that Sub when an Add-in is loaded instead. How can I do that? ...

How can I output a report in PDF format, where the name consists of values from fields?

I want to add functionality to my Access 2007 report whereby a PDF copy of the report is created at the click of a button. I know that there is an OutputTo macro which can do this for me, but it does not allow me to include report field values as part of the PDF's filename, namely: [Client Organisations].Code + "-" + Clients.Code + "-" +...

How do I add put a border around every 2 lines in excel worksheet

hi, can someone please give me some guidelines on this. I'm fairly new to VBA. After outputing data to a worksheet, i want to format it. How do I add put a border around every 2 lines in an excel worksheet using VBA? regards Kojo ...

Is VB Really Case Insensitive?

I'm not trying to start an argument here, but for whatever reason it's typically stated that VB is case insensitive and C languages aren't (and somehow that is a good thing). But here's my question: Where exactly is VB case insensitive? When I type... Dim ss As String Dim SS As String ...into the VS2008 or VS2010 IDE the second one h...

VBA Assign a value to a cell inside a function?

Hi, Is there anyway that I can assign a value/name to cell within a function ? Thank you EDIT Sorry for being unclear, here is my requirement. I'm having a user defined function (=MyFunction()) which can be called from a excel sheet. Thus, I also having a menu button where I need to recall the all the functions calls to =MyFunction(...

How to Retrive cell addresses which call specific function

Hi, I need to find out cell addresses which has called a specific function, If my function is MyFunction (arg1, arg2), I should be able to find the cell addreses using name "MyFunction". Please help me to find out what would be the most efficient way to do this. Thank You ...

Can I return a byte array from a SQL Server VarBinary column using a parameterized query?

I wrote a small VBA procedure to test uploading and downloading of files as binary data into and out of a VarBinary column in SQL Server using ADO. The upload process appears to work, but I cannot get the download process to work. I believe the output parameter for VarBinary is setup incorrectly, but I cannot find any documentation on h...

VBA to Javascript

I built a macro in Excel to pull data from a website and I'd like to recreate that macro in a Google Spreadsheet (regular or apps). The excel file uses VBA and I believe google only uses javascript. Is there a way to get around this? I don't know javascript and wouldn't be able to use what I built in google. ...

WIA Document Handling Status returns 0 even though the ADF has pages loaded

I'm trying to scan from an ADF using VBA and the Windows Image Acquisition library (WIA). I am trying to check to see if there are pages loaded in the ADF so I know whether to scan another page. This function seems to work well in Windows 7 (my dev machine) but not in Windows XP (the production machines). I know MS made some changes t...

VBA: Test network drive connection speed.

What is a good way for excel to test network connection speed to the network drive my excel project is stored on? Many of my clients have been complaining that my excel project runs too slow (running it off the network). This is because some of the offices have slower connections than others to the network drive where it (and its acces...

parameterized query in ms access 2003 using vba

Ok. I want to use parameterized queries to avoid dealing with embedded double or single quotes (" or ') in my data. As a simple example, what would the VBA code look like for the parameterized verion of this? Dim qstr as String Dim possiblyDangerousString as String qstr = "SELECT MyTable.LastName from MyTable WHERE MyTable.LastName ...

Why can't I do a "with x as (...)" with ADODB and Oracle?

Hello I fail to execute an SQL query with a with clause via ADODB and Oracle. That is, the following snippet works: Dim cn As ADODB.connection Set cn = .... Dim rs As ADODB.recordSet Set rs = New ADODB.Recordset rs.Open "select 'foo' x from dual", cn Do While Not rs.eof ... rs.MoveNext Loop However, the following doesn't w...