excel-vba

C#: Excel 2007 Addin, How to Hook Windows Activate and Deactivate Events

I am writing an Excel 2007 Addin. using VS2008 and .net 3.5, C#. I catched Microsoft.Office.Interop.Excel.Application's WindowActivate and WindowDeActivate events. It was surprised to know that WindowActivate and Deactivate only triggers when i switch between two Excel Windows. if i switch to notepad, i expect Deactivate to be trigger...

How to determine if there are hidden columns when copying in Excel VBA

As the title explains, I have an Excel 2003 workbook and I'm copying a number of columns of one sheet to another in VBA. Unknown to me, someone has hidden a few columns on the source sheet and it has messed up how I process the cells in the destination sheet. How can I programmically determine: IF there are hidden columns WHICH colum...

How can I copy an Excel sheet into a workbook whose windows are not visible?

source.Sheets(RevisionHistory).Copy before:=target.Sheets(1) This does not work when all the windows for the 'target' workbook are not visible. When Visible=True for them, then it works. The easy answer is just to make them visible. But, they are being worked on and it a problem for the user to see all that activity. ...

Excel text split

Sample Modified and self-produced (d) Food packages (d,d,d,d,e,e,d,d,e,d,d) Other country’s food labels (d) Using food labels to choose foods for Healthy eating (d) Measuring cups food models (d) Food labelling exercise – custom (e) Food product promotional pamphlet (d) It pays to read your grocery label (d) Old food labels (d)...

How do I replace the formula in a cell with the output of the formula?

How do I replace the formula in a cell with the output of the formula? I simply need "=RIGHT(E86,LEN(E86)+1-FIND("(",E86,1))" to become "(e)" Is there a way to do this to the whole sheet? Replace all the cells with formulas with the text they are displaying? I am using version 2003. ...

excel vba: functions as arguments of functions

There is no special type for functions, therefore it is hard for me to see, how to add functions as arguments to functions in excel vba. What I try to accomplish is something like this: function f(g as function, x as string) as string f = g(x) end function Concerning the motivation: I have a masse of little functions all repe...

c# excel legend...

hi, i am using vsto, to work with excel-2007... let's consider i have a matrix as follows A B C 1 10 11 12 2 10 12 11 3 11 10 12 i will always read some random matrix filled with random numbers... ex above, and the other condition is that they will also be colored randomly according to the same numbers...

excel vba for each loop takes 2 steps at once

I want to process every element of a for-loop. Taking this code, why is just every second element processed? For Each row In ws.Rows If IsEmpty(row.Cells(row.row, 1)) Then Exit For Else MsgBox row.Cells(row.row, 1).value End If Next Thanks in advance for your answers! ...

excel-2007 record macro

1) hi i just wanted to know why excel-2007 record macro does not write anything for example when i do the following: i insert a rectangle on the sheet and change its backcolor... (on the other hand, if i do the same thing in excel-2003 i get some code) 2) also is it possible to using vb to ask excel to put the rectangle on specified p...

Draggable data points in Excel 2007?

I know Microsoft removed draggable points in 2007, but I need to get that function back. So far, I've got the MouseDown and MouseUp events trapped, but I'm having trouble figuring out how to scale the cursor's movement (which is measured in pixels) to a change of the selected point (arbitrary scale) Using VBA, how can I find the heig...

excel-2007 zoom in zoom out

hi is it possible to write something like zoom-in and zoom-out button... for example i will have a userform on which i will have two buttons one for each zoom in and out... whenever the user clicks on one of the buttons plus user clicks the cells (or selects the range) that cell or range will be increased or decreased using the ActiveWi...

Whether to enable a security-protected feature

An Excel spreadsheet needs programmatic access to its Project structure. However, this access is disabled by default. It can be enabled programmatically, by writing to the registry with this snippet: Set wsh = CreateObject("WScript.Shell") 'key to modify' str1 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Office\" & Application.Version & "...

Where can I find documentation for Excel's Pictures collection?

I have seen many references to doing something like the following to insert a picture in Excel: Set p = ActiveSheet.Pictures.Insert(PathToPicture) Where can I find the canonical documentation for this? ...

Re-Initializing "ThisWorkbook.Path"

First, thanks to those of you who gave me the suggestion on using "ThisWorkbook.Path". It worked like a charm. However, my code walks through seven (7) workbooks and when using "ThisWorkbook.Path" I can not re-initialize the "This.Workbook". Let me elaborate. This is the workbook where the Macro resides: Workbooks("Financial_Aggrega...

c# excel zoom in and out button

hi i have a c# program which creates a ribbon on excel-2007, on that ribbon i have two buttons one for zoom in and other for zoom out. my question is how is it possible so that when i press one of the above buttons and then select the cell or range on a sheet that cell or range will be zoomed in or out? my problem is i do not know how ...

Copy Excel worksheets, macros, and graphs from one workbook to another, moving links to the new workbook

I have an Excel workbook with a number of features: One main user-facing sheet One summary sheet based on the user-facing sheet's data A number of graphs based on the user-facing sheet's data (as in, the type of graphs with a separate tab for them, rather than objects within a worksheet - I'm not sure if they have a special name or spe...

VBA changes Excel 2002 -> Excel 2007

Where can I find a complete list of changes in VBA from Excel XP (2002) to Excel 2007? I have a workbook that relies heavily on VBA which I have been working on in 2002, and when I opened it in 2007, I noticed that some things had changed. For instance, my workbook does lots of 3d rotation; I discovered that Shape.ThreeD.RotationX has ...

Error 70 in Excel VBA

Hi, I am trying to upload directly a picture/chart from excel to a Sharepoint group URL. Here is the script: Sub ExportChartJPG() ActiveChart.Export Filename:="http://sharepoint.ap.xxxxxxxxxxxxxx.com/xxxxxx/xxxxxxxxxxxxxx/Pictures/MyChart.jpg", _FilterName:="jpeg" End Sub Is that possible? If it's not then can you suggest anothe...

Display selection at upper left corner of spreadsheet

hi is it possible to do this kind of things in excel-2007 vb... for example user selects cell or range.... let's say cell G13, now this cell will be displayed on the upper-left corner of the sheet (i.e. where usually A1 resides by default) in the case of range selection the upper-left corner of the range will be displayed in upper-left ...

Visual Basic dot operator syntax--no object name

In a former life I wrote some Visual Basic, and today I need to resurrect those skills to write an Excel Macro. While trawling the Internet looking for VBA examples to help we with this Excel macro, I came across this unusual syntax: Set rFound = .Columns(1).Find(What:="Cat", After:=.Cells(1, 1), LookIn:=xlValues, LookAt:= _ xlP...