vba

Hungarian in VBA okay?

I don't use hungarian (str, int) prefixes in .Net, but I still find it useful in VBA, where it is more difficult to see types. Is this bad? Unnecessary? Maybe I'm missing something. I'd really appreciate any feedback. I've been wondering for a while. Thanks everybody. ...

Should I use Call keyword in VB/VBA?

I use the Call keyword used when calling subs in VB/VBA. I know it's optional, but is it better to use it or leave it off? I've always thought it was more explicit, but maybe it's just noise. Also, I read this on another forum: Using the Call keyword is faster because it knows that it is not going to return any values, so it doesn't n...

How to Pretty print VBA code?

I need to "pretty print" VBA code into a Word document, retaining the color scheme from the VBE editor. I've been looking for free programs or methods to do this, but found nothing usable so far. Any ideas would be greatly appreciated. Thanks ...

MS Access 2003 - Failure to create MDE file: error VBA is corrupt?

Ok so this is a brand new snag I have run into. I am trying to launch a new MDE from my source MDB file, and it is locking up Access. So in my mdb, I am first compacting and repairing, and then selecting create a new mde (just as I have done many times before). It looks like it is starting the process, but never gets to where it comp...

Using Excel VBA to send emails. Problem with attachments becoming embedded by accident.

Hi, I am having an issue with an Excel macro I wrote that is used by several users within my company. It is used to send numerous emails daily with attachments that are also Excel workbooks. The issue is that sometimes, instead of the file simply being attached as it should be, it becomes an embedded object. This embedded object is opena...

Looping through recordset with VBA

I am trying to assign salespeople (rsSalespeople) to customers (rsCustomers) in a round-robin fashion in the following manner: Navigate to first Customer, assign the first SalesPerson to the Customer. Move to Next Customer. If rsSalesPersons is not at EOF, move to Next SalesPerson; if rsSalesPersons is at EOF, MoveFirst to loop back to...

Excel 2003 VBA - Method to duplicate this code that select and colors rows

so this is a fragment of a procedure that exports a dataset from access to excel Dim rs As Recordset Dim intMaxCol As Integer Dim intMaxRow As Integer Dim objxls As Excel.Application Dim objWkb As Excel.Workbook Dim objSht As Excel.Worksheet Set rs = CurrentDb.OpenRecordset("qryOutput", dbOpenSnapshot) intMaxCol = rs.Fields.Count If...

Excel 2003 - VBA for looping through every cell in a row to provide attributes/formatting

say I want to make the first row of the excel ss something like this: .Rows("1:1").Select With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = xlAutomatic End With ...

How to populate data from .txt file into Excel in VBA?

I'm trying to create something to read data from a .txt file, then populate data into .xls, but after open the .txt file, how do I get the data out? Basically I'm trying to get the the third column of the lines dated '04/06/2010'. After I open the .txt file, when I use ActiveSheet.Cells(row, col), the ActiveSheet is not pointing to .txt ...

How to reference an embedded PowerPoint or Excel file in a form in Access?

So if I was to take a an Access form, and embed either an Excel spreadsheet into it or a PowerPoint deck, how would I reference it in VBA code? I know I have to set the libraries, name the frame of the OLE object, and use applicable syntax to whatever I want to do, with whatever I stick in the form, however the only things I have ever d...

How can I make Outlook 2007 auto BCC messages to a specific email with specific words in subject using VBA?

So far I have this code from outlookcode.com which I can get to work sending all emails I send to the BCC email. I am not a developer, so I don't have a lot of context to go about editing this myself, or even approaching researching this. If anyone knows how to make this check for words in the subject, or check if the subject equals a ce...

How to get the idle time in Windows XP using VBA?

I would like to know the current idle time from user input on a given Windows XP machine programmatically. I am using VBA in MS Access. What options do I have? ...

Date Difference, Excluding certain Times and Dates

Hi Folks. I'm looking for a way to determine the difference between two dates. A normal SQL DATEDIFF statement won't cut it because I need to excluded non working Hours and days Namely Weekends and any time between 16:00 - 7:00. Something similar to the NETWORKDAYS function in excel. I'm codeing an excel spreadsheet. Using VBA connec...

Macro VBA to get selected text in Outlook 2003

I am trying to use this code snippet to get the selected text in outlook 2003 Sub SelectedTextDispaly() On Error Resume Next Err.Clear Dim oText As TextRange ''# Get an object reference to the selected text range. Set oText = ActiveWindow.Selection.TextRange ''# Check to see whether error occurred w...

How do I pass a Range to a Sub in Word VBA?

I know this sounds simple, but seemingly it is not. If I write this in Word VBA, it always says "incompatible types" - why? And how do I make it work? Thank you very much for your help! Sub GetRange() Dim r As Range Set r = ActiveDocument.Paragraphs(5).Range ProcessRange (r) End Sub Sub ProcessRange(r As Range) Debug.Pr...

Excel Question: I need a date and time formula to convert between time zones

Hello, I am trying to find a way to calculate a duration in days between my, time zone (Central), and (Pacific; Mountain; Eastern). Just do not know where to start. My criteria would be as follows: Cell C5:C100 would be the timestamps in this format:3/18/2010 23:45 but for different dates and times. Cell D5:D100 would be the correspo...

Replace or recode several different values by a single value in an Excel file

Hi all, I have an Excel worksheet which contains data in several columns. For a specific column, I will need Excel to replace all values between, say 10 to 15, by the value 1 and values between 16 and 20 by the value 2 and so forth. I know how to do it for a single value; ie: I can replace value 10 by 1, 11 by 1 and so on. But this wil...

WORD 2003 - Adding Hyperlinks to other files....can I use currentpath in the hyperlink

I have a document that is an overview document within a folder, there are numerous related documents in a folder that is also in the folder that contains the overview document. I would like to reference these documents throughout the overview document and allow those to be selected and viewed by clicking. so i was going to use a hyperl...

violation of primary key constraint .Cannot insert duplicate key in object using ADO

Hi All we are working on a users apllication using Access2003(VBA) as software language and SQL Server 2005 as database. We are using ADO method and we encounter a problem. when users create new record in a ADO Screen and they want to save the record after implementing it they receive this error : error -2147217873 violation of primary ...

MS Access Draw line around detail section that can grow

This really shouldn't be hard, I just can't figure out how to do it. I am making a proposal report that needs to have a border around it. The problem is to get the vertical lines on the side. I can't figure out how to get a line to grow and shrink based on the height of the detail section. I have used Crystal reports and sure wish Mic...