vba

vba: get location of current worksheet

i wrote a macro that is an add=in it needs to figure out the location of the current worksheet on which it is being executed. how do i do this? i need the file location (directory) ...

running a macro from an add-in

i have an add-in called book1. inside the addin there is a module called module1 which has a sub called addin1 i would like to run the macro addin1 from a different workbook i am trying to call this macro like this: Call Addin1 but that's not working and i tried: Call book1.xlam.Module1.AddIn1 which is not working either does a...

getting the heading of a selected text in word

Hi, I am working With Microsoft Word VBA,macros,.net My question : Is there way to get sub-topic and master-topic that precedes a selected body text ? Here is an example: Master topic (level 1) sub-topic 1 (level 2) body text a body text b body text c sub-topic 2 (level 2) body text d body text e Other MISC topics (level 2) bo...

Word 2007: mail merge hyperling from data field

Not really hard core programming, but it's been bugging me. I need to do a simple mail merge and in the merge I need to personalize the url. It seems like the only option is to use a macro (alt-f9 field editing doesn't work as expected), but I just cant get it running. I've created an EventClassModule as described here: http://msdn.mic...

excel vba: writing to mysql database

i would like to write a macro that will write to a mysql database. can someone please get me started on this? ...

connecting to mysql from excel: ODBC driver does not support the requested properties.

i am trying to add data to mysql from excel. i am getting the above error on this line: rs.Open strSQL, oConn, adOpenDynamic, adLockOptimistic here is my code: Dim oConn As ADODB.Connection Private Sub ConnectDB() Set oConn = New ADODB.Connection oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _ "SERVER=localhost;" & _ ...

Why isn't my iif statement evaluating true when the condition is correct?

This is my statement: iif(sum(Fields!myfield1.Value) = 0, 0, sum(Fields!myField2.Value)/sum(Fields!myField1.Value)) Any suggestions? ...

"run-time error '453' can't find dll entry point" from vb.net compiled dll referenced by vba

I am coding in vb.net through visual studio 2008. I have successfully compiled a dll file from my code but I continue to get "Run-time error '453'" when I try to reference the dll in vba. I understand there is some sort of compiling error that occurs when using vb.net. Does anyone have any suggestions to fix/overcome this issue? I would ...

what does select @@identity do?

i am connecting to a mysql database through excel using odbc what does this line do? Set rs = oConn.Execute("SELECT @@identity", , adCmdText) i am having trouble updating the database: With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields...

Making an Excel file into a link in VBA.

Mvalue = MonthName(5, True) fileL = \bobby\outside\" myFile = fileL & Mvalue & Right(Year(Date), 2) & "\Goodbye - " & myfdate & ".xls" Set omail = CreateItem(olMailItem) With omail .Subject = "Hello" .BodyFormat = olFormatHTML .HTMLBody = myFile How do I make the.HTMLBody = myFile, into a link within the email that ...

how do i update database using ADODB.Recordset?

i am using excel to connect to a mysql database: Dim dpath, atime, rtime, lcalib, aname, rname, bstate, instrument As String Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset ConnectDB With wsBooks rs.Open "batchinfo", oConn, adOpenKeyset, adLockOptimistic, adCmdTable Worksheets.Item("Report 1").Select ...

difference between cn.execute and rs.update?

i am connecting to mysql from excel using odbc. the following illustrates how i am updating the rs With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields("analysistime") = atime .Fields("reporttime") = rtime .Fields("lastcalib") = lcalib .Fields("ana...

what does this ADO OPEN Method do?

in plain english can you explain to me what happens here: rs.Open "batchinfo", oConn, adOpenKeyset, adLockOptimistic, adCmdTable what i need to do is to be able to insert values into a table called batchinfo. would this be the best way to do an OPEN? the only thing i would be doing is inserting values. ...

ms-access: missing operator in query expression

i have this sql statement in access: SELECT * FROM (SELECT [Occurrence Number], [1 0 Preanalytical (Before Testing)], NULL, NULL,NULL FROM [Lab Occurrence Form] WHERE NOT ([1 0 Preanalytical (Before Testing)] IS NULL) UNION SELECT [Occurrence Number], NULL, [2 0 Analytical (Testing Phase)], NULL,NULL FROM [Lab Occurrence Form] W...

ADODB: difference between ADDNEW and UPDATE methods?

i am updating a table in mysql using ADODB i am adding new entries into a table should i be using addnew or update? ...

VBA Excel 2007 macro dies in Excel 2002

Hi, I have just tried to send a workbook to a friend that has a chart with a drop-down box on it. In excel 2007 I have used: If Chart2.Shapes(2).ControlFormat.ListCount = "16" Then To check the size of the list so that it doesnt get entered in again (resulting in an extremely long list that repeats itself). This line works well in Exc...

How to get the MD5 hex hash for a file using VBA?

How can I get the MD5 hex hash for a file using VBA? I need a version that works for a file. Something as simple as this Python code: import hashlib def md5_for_file(fileLocation, block_size=2**20): f = open(fileLocation) md5 = hashlib.md5() while True: data = f.read(block_size) if not data: br...

Named Range Breaks Code

I have one workbook with several sheets. I populate the listboxes (pulling static data from cells) on the 2nd sheet, click a button and it runs fine. When I populate the listboxes with a named range, the listbox populates the way I want, but I get an error because the code thinks that I didn't select anything in the listbox, even though...

adodb: what does createparameter do?

in plain english can you please explain to me what does this line mean: Cmd.Parameters.Append _ Cmd.CreateParameter("datapath", adChar, adParamInput, 100) i then have a line that writes data to the datapath column: Cmd.Parameters("datapath").Value = "abc" but i do not understand the purpose of the first line? what is adChar and...

vba: funny notation with #??

what does this mean? if CDbl(Trim(Range("M" & r).Text)) > 0# then... what does the # do?? and what does cdbl do? ...