vba

Space Delimited 'Export To Text' Excel Macro Issue

I have the below vba macro to Export the selected cells into a text file. The problem seems to be the delimiter. I need everything to be in an exact position. I have each column's width set to the correct width(9 for 9 like SSN) and I have the cells font as Courier New(9pt) in an Excel Sheet. When I run this it comes out REALLY c...

How to get selected text in VBA

I have a macro, that change selected text, assigned to button. It works perfectly when i run macro from visual basic, but when I click button it gets focus and my text is no longer selected so macro change selected element (button). How can I select text and run macro by click on button? ...

Access get all tables

Dear All, Is there a way in by sql statement or vba code to return all tables from access file? "I don't know the name of the tables" like when you want to have all fields in a table you use '*' regardless the names of the fields. but how to get all tables?!!!! ...

with vsto and excel more and more trying to incorporate visual studio and C#, is VBA dead ??

what is the future for excel vba? it seems like excel is on its third or fourth version of trying to get VSTO as the mainstream solution here. Is there a clear strategy? is vba going to die anytime soon? ...

best content on how to deploy and share a VSTO solution

with the push to leverage visual studio and dotnet with office based solutions, especially excel, where is the best article or information on how having office sheet with additional binaries and assemblies is sharable. Do this external code get packaged with the spreadsheet what if people start emailing the spreadsheet around. Is th...

Use code to do a screen capture of an application running

I need to run some code to capture the window of an application running on the windows desktop (windows XP is fine here). There are a number of VB6 examples on the web, but they tend to capture the running VB6 application or the desktop only. I am looking for a solution that captures a given window/application. So, I want to be able to ...

pass sheet to a function (excel vba)

I've been trying to pass a sheet in my workbook to a function, but it doesn't seem to be working. The function is Private Sub passToSheet(theData As Variant, Optional mySheet As Worksheet) I have tried doing Dim mySheet as Worksheet Set mySheet = "Results" then to call the function passToSheet theData mySheet but it doesn't seem...

Query Excel worksheet in MS-Access VBA (using ADODB recordset)

I'd like to query an Excel worksheet in VBA and specify conditions. The simple query "SELECT * FROM [PCR$]" works perfectly, but I don't know how to add a WHERE clause. I tried cmd2.CommandText = "SELECT * FROM [PCR$] WHERE ([B1] IS NOT NULL)" but then it complains about missing parameters. This is the complete code: Dim rs2 As New ...

listing files works, but how do I list files within folders (VBA, excel)?

I have some code which I found online and it's working great. It lists any files in a specified folder and their properties. I just need to amend this function which returns a list of files. I need it to look in a given path at ALL files. So if it's a folder, open it and return those files too. I eventually need to get this to mark each ...

Combine multiple cells into one in excel with macro?

I have a similar question to this one: http://stackoverflow.com/questions/621862/merge-the-contents-of-2-cells-into-another-3rd-cell-using-vba-in-excel But I want to combine a range of cells within a column, eg A2:A50. Sometimes I have over 300 cells to be combined into one. Values are text. Is there any way to modify this macro so tha...

Memento Implementation in VBA

Hi, I'm looking for a VBA implementation of the Memento pattern (GoF). I'm looking at converting the Java version from Wikipedia. It will be used for Undo/Redo functionality for an Excel add-in. Specifically, I am having difficulty with the line: return new Memento(state); Or, to make it more specific, can someone rewrite this in VB...

neat way to get last friday's date

no matter what day I call the function on. I know I could write a select case weekday(now) statement, was just wondering if there was a neater way to go? ...

What do I need to do to set up Visual Studio to be able to manipulate an Excel File?

Let's say I want to find the value of a cell in an Excel file. In VBA, I would do this: Dim varValue As Variant Dim wb As Workbook Dim ws As Worksheet Set wb = ThisWorkbook Set ws = wb.Worksheets("Sheet1") varValue = ws.Range("A1").Value How do I set up a Visual Studio project so I can access and modify an Excel file in C# rather tha...

VBA - Popup message when user try to print

Hi guys I am needing to set-up a function in MS Word to run a message box when a user tries to print a particular file. Cheers Anthony Update - I haven't done any VBA before and am trying to help out someone who need this. What they need is a message box with some text to display when the user goes to print this particular document...

Getting return values from an embedded Internet explorer

I know how to open an Internet explorer from within an VBA application. But how to I get "return" values from the running explorer to the VBA application. E.g let us assume I try to access http://page_not_there and got back an Error 400 How can I get this value in my VBA Application and act accordingly. Any hints or links or programmin...

Find Text Cells That Are Too Small to Display Contents

I have a worksheet with cells that may contain text that sometimes exceeds the width and height of the cell. If I don't notice it and adjust the row height, the text shows up as cutoff. Does anyone have a VBA snippet or tool that can locate these cells so I can adjust them? Thanks! ...

Excel VBA: force refresh of "last" cell of the worksheet

Pressing Ctrl+End in Excel takes you to the bottom-right-most cell of the worksheet. If you delete the last rows or columns and save the workbook, this last cell gets updated (and the scroll bars do to). I remember there was a one line vba command that you could run that would do the update without having to save the workbook, but I ca...

How to avoid Excel localizing object names and breaking macros?

I have this line of code in my macro: ActiveSheet.ChartObjects("Chart 6").Activate When I open the file and run the macro on a non-English version of Excel, this code breaks. For example on the Japanese system I tested it on, I would need to change the previous line to: ActiveSheet.ChartObjects("グラフ 6").Activate (グラフ means Chart in...

Extract the mail id of an Outlook e-mail message

I want to extract the mail id from mail in the Microsoft outlook 2007; how can i do it using the macros. ...

excel - how to duplicate each row with a macro

I have excel sheet with N+1 rows where Column A has unique id N. I need to duplicate each row so that below a row N there will be three new rows with unique-ids N-b, N-c, N-d e.g. sample input rows: id1 data here id2 data2 here e.g. sample output: id1 data here id1-b data here id1-c data here id1-d data here id2 ...