vba

Using an Array of Ranges in VBA - Excel

Does VBA support using an array of range variables? dim rangeArray() as range dim count as integer dim i as integer count = 3 redim rangeArray(1 to count) for i = 1 to count msgbox rangeArray(i).cells(1,1).value next I can't get it to work in this type of application. I want to store a series of ranges in a certain order as a "ma...

Outlook olMailItem.Attachments.Add - does an attachment have to be on the filesystem?

Is there a way to add an attachment to an email you're sending out without the attachment being on the filesystem? From reading over the DOM (http://msdn.microsoft.com/en-us/library/bb175153%28office.12%29.aspx) it says that the attachment source can be either a file path or "an Outlook item that constitutes the attachment". I don't use...

VBA Macro -- How can I access the clipboard?

Hello all. I'm new to programming, so this is (hopefully) a simple question. I'm catching cut, copy, and paste operations in Microsoft Word via macros -- currently, messages like "PASTE!" pop up when a paste operation takes place, etc. However, when these messages pop up, the actions themselves do not take place. For example, if I have ...

Word VBA Macro -- Write multiple items to a txt file?

Hello all, I'm working on a project to store what a user cuts/copies/pastes within a Word document, and am using the VBA macros to accomplish this. Here's a snippet from the paste macro: Open "C:\Temp\HoldPastes.txt" For Output As #1 Write #1, "TestTestTest." Write #1, Selection Close #1 I'd like HoldPastes.txt to h...

outlook security in asp.net webpage

I used http://www.everythingaccess.com/tutorials.asp?ID=Outlook-Send-E-mail-Without-Security-Warning , to finish my first ms access vba app that sends multiple notifications via outlook, without security pop-up. Now I want to make a WEB BASED version of it. So, using asp.net & mysql instead of vba & access raises certain questions. ...

Open Word document from Internet Explorer on intranet

We have an internal website for document management. When you choose to open a document, it run the following script to open the file: <a href="javascript:opendokument('P:\\01\\2-010-01.doc')">012-010-01</a> <SCRIPT language=javascript> function opendokument(dokument){ var objAppl; try{ objAppl = GetObject("","Word.Applicatio...

I am getting run time error 462.

HI, I have the following piece of code in Access. Dim objSht As excel.Worksheet Dim objexcel As New excel.Application Dim wbexcel As excel.Workbook Dim wbExists As Boolean Dim objRange As excel.Range Dim isFileAlreadyPresent As Boolean Set objexcel = CreateObject("excel.Application") Set wbexcel = objexcel.Workbooks.Open(file_name) ...

Vba - Set transparent color or direct hex value of label backcolor?

Hi, I want to insert a label into a PowerPoint presentation. But I don't want any background on there, or, have the background color be the same as the what is underneath. I've found that 082F68 is the hex code I want. The RGB code is: 8, 47, 104 This color is supposed to be bluish, but when I insert it, it just gets brown. I really d...

VBA Word Range Operations Seem Different

In using or setting Ranges, some Ranges behave differently that other Ranges. For example, ActiveDocument.Range(10, 20).Select ActiveDocument.Tables(2).Cell(1, 1).Range(10, 20).Select The first line if OK and works as expected. The second line produces an error on the Range statement, although it seems that two lines should be identi...

Trigger MS Word macro after save event

My MS Word 2007 template has a footer with the filename in it. The user is going to open the template and do a "Save As..." to make their document. I want the filename shown in the footer to update immediately to the new filename. Is there an AfterSaveEvent or something that I can use as a hook to start my VBA script that does the upda...

Referencing VBA assembly in c#

Guys, How do I reference VBA assembly in C# application from Visual Studio 2010? I can not find it in "Add Reference" dialog box. This is the reason why I need it: Error 1 The type 'VBA.Collection' is defined in an assembly that is not referenced. You must add a reference to assembly 'VBA, Version=6.0.0.0, Culture=neutral, Public...

User-defined type not defined for AppointmentItem in Excel

I copied example at http://support.microsoft.com/kb/220595 to the VBA in Excel. My code follows: Dim olApp As Outlook.Application Set olApp = CreateObject("Outlook.Application") Dim olAppt As Outlook.AppointmentItem Set olAppt = olApp.CreateItem(olAppointmentItem) I obtained the following error on the line Dim olAppt As Outlook.Appo...

How to select range of filled cells using macro

I have a button in sheet3.On the button click event I'm calling a macro.In the macro I want to select the number of cells that are filled in sheet13.How do I do this ...

How to record delete event in excel

I have a situation where I need to know if manually a delete was performed on any row in my spreadsheet.How can I record this event in vba. ...

VBA: Open an xls file and add it to the current workbook.

Hey all, I am having trouble with this one. I have an xls file which contains a single sheet of data. In my main application, a different workbook, I want to open this single sheet xls file and copy the sheet into the current workbook. I can do it if I select the range on the source file to copy but this single file may change so I...

How can I make the Excel cell menu update when the keyboard's context menu key is pressed

At the moment, I have code that runs in the Application's SheetBeforeRightClick event, but I've found that this code doesn't run when I press the keyboard's Context Menu key instead of using the right mouse button, which means that I get the wrong menu. I could use the SheetSelectionChange event instead, but I'd imagine this would be qu...

How to delete a record and assign an existing record in its place.

Hi there I'm wondering if anyone could help me out here. Is it possible when deleting a record to assign all instances of the deleted record to a new record? For example: For each project in a time planning database, i can assign a worker as team leader for each project. If there was a duplicate entry for a team leader i would need t...

How to save an SQL file using Save Dialog in excel

I'm creating an SQL file using Application.Path & SQL_statements.After that I write SQL statements into this file through vba.Now I want to save the file after all SQL statements are generated in an different directory.This directory depends upon the user.Hence I want to give him an Save as Dialog . Thus, I need to save the file that I ...

How do you query a website in vb6?

What is the function to query the web from vb6? What I am trying to do is to get data from yahoo finance. For example this url returns a csv file with the dividend value of General Electric: http://finance.yahoo.com/d/quotes.csv?s=GE&amp;f=d I need to run this in a function and have the function return the answer. ...

How do I make an arbitrary string email address safe?

I need to take an arbitrary string and make it safe to use as part of an email address, replacing characters if necessary. This is to submit text to an API that requires values to be encoded into the address the email is being sent to. However, this is fraught with pitfalls and I'd like to make sure that whatever is input isn't going to ...