vba

How do i make a string bold

hi, I'm creating a word document programatically using VBA. 1) I have a a string with value - "Strategy". I want to make it bold and to be displayed in the word document. I have tried this below, but the text is never changed: Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Set wrdApp = CreateObject("Word.Application")...

Excel commands not available when macro is paused

In Excel 2003, I was able to pause a macro switch to Excel and perform excel functions, then switch back to VB and resume the macro. In Excel 2007 when I pause a macro and switch to excel, most of the excel functionality does not respond. I can switch between sheets and perform 'browse' type functions, but I cannot change cell values or...

Type Mismatch error calling C# dll from VBA using com interop

What are the limitations for parameters when calling C# methods from VBA code using COM interop? I'm finding that if I call a method that takes a single simple type (string, int, etc) it works, but calling a method that takes a custom class as a parameter fails - with a 'Type Mismatch' error while compiling the VBA code. C# code: ...

Excel VBA WinHttp How to submit a form

I'm using WinHttp to access an URL, say "http://server/application?id=abc" When I try to URL from Explorer, I get an HTML table with lots of info. However when I try from Excel VBA like this: ht.Open "POST", "http://server/application?id=abc", False ht.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" ...

relative link failure in ie8

Private Sub RenameHyperLinks(d As Document) ' ' RenameHyperLinks Macro ' ' Dim oFld As Field Dim oldString As String Dim newString As String Dim dp As Object Dim link As Hyperlink Set dp = d.BuiltInDocumentProperties 'Set Base Hyperlink for document to relative path dp("Hyperlink base") = "..\" For ...

How to find the X and Y co-ordinates of points on an Excel scatter plot

I've got a scatter plot which I generate and set the data for programatically. The only problem is that if the data series are close together the labels find themselves right on top of each other. I have an algorithm in mind for moving the labels around so they remain close to their corresponding data series and are positioned so that t...

Using NOT LIKE in Filter property of VBA recordset

I am using excel 2003 to connect to SYBASE database using VBA recordset. I want to filter the records. Following is code I have used. Dim rset As New ADODB.Recordset rset.Open sQuery, m_db, adOpenForwardOnly rset.Filter = "Name NOT LIKE 'Dav%'" rset.Requery But it is not working and returning all rows. If I use Name LIKE 'Dav%', its ...

Pass an array from vba to c# using com-interop

What is the proper way to pass an array of user defined classes from vba to .net (specifically c#) using com-interop? Here's my c# code. If I call Method1 from vba it's failing with "Array or userdefined type expected" or "Function uses an automation type not supported in visual basic". public class MyClass { public Method1(UserD...

Add a cell formula in Excel via vba

Hello, I’m not an Excel or VBA expert but I want to insert this current excel formula into cell’s using VBA. Current Excel formula: =IF(OR(ISNUM(D570)=FALSE;ISNUM(D573)=FALSE);"";IF(C573="Total";D573-D570;"")) VBA formula : ActiveSheet.Range("a" & ActiveSheet.Rows.Count).End(xlUp).Offset(2, 12).Value = "=IF(OR(ISNUM(R[-3]C[-9]...

Excel VBA development best practises

We are an ISV with experience developing and distributing desktop applications written in VB6. We are now developing tools as Excel spreadsheets containing VBA code. These will be downloadable free for various users including local government organisations. We've rarely distributed spreadsheets outside our own organisation before. What...

Add an Image to Word Document and Scale it using VBA

hi, how do i programatically add an image using VBA to a word document. I've tried adding a bookmark to the word document and tried adding the image, but it always adds to the top of the form rather than the bookmark area. Should i persevere with the bookmark or is there another way to add the image? See my code below: Dim wrdApp As...

Is there a way to use OLE DB Provider for Jet on an unsaved Excel workbook?

I am working with the Microsoft OLE DB Provider for Jet to execute queries on spreadsheets in Excel using VBA. Is there a way to execute the following code on an unsaved workbook? For example, ActiveWorkbook.FullName returns "Book1" if the workbook has never been saved. In that case the Data Source will assume the path is the active dir...

Excel 2003 doesn't have WorkbookConnection class

How to get over this problem Excel 2003 does not have WorkbookConnection class while 2007 have it. ...

How to install a Vimball plugin (with .vba extension)?

How to install a Vimball plugin (with .vba extension)? The documentation just says: install details Edit the vba file and type: :so % the vimball documentation says: All a user needs to do with a vimball is: vim someplugin.vba :so % :q Do I have to write that in normal mode (inside Vim) or in the _vimrc file? Do I have to write t...

acDiaglog - vba

Hi I would like to know what does this "acDialog, "x" means? it's a VBA code. Case "btnInfo" DoCmd.OpenForm "Info", , , , , acDialog, "x" ...

Excel: Runtime error 13 type mismatch

I got Run-time error '13' at then end of this code, even if I try to switch between the commented lines of code Public Property Get cnnString() As String 'old: strcnnString = "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & Me.DBFolderName & ";Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:S...

Access VBA - print last record from SQL Query

Hey I have the following SQL Query I'm executing and I'm trying to find why it returns the error 'overflow' when running the query. Now I want to print the last record that it computes before going into overflow, is this possible using MS Access VBA? Private Sub Command0_Click() Dim sql As String Dim rs As DAO.Recordset Dim db As DA...

migrating vba project from excel 2007 to excel 2003

Dear all, as in my question title I am re-writing code of excel vba 2007 project to work with excel 2003, so instead of using connections in 2007 I will use queryTable in 2003, so my problem is if the connection string in 2007 is strcnnString = "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & Me.DBF...

Using VBA to Copy special symbols from one PowerPoint presentation to another

I need to copy text from one PowerPoint presentation to another. However, I have problems copying special symbols, such as smileys, which appear in the target presentation as empty boxes. Looking at the Open XML file in the original presentation, I can see that the Run containing the smiley has a "SymbolFont" attribute: < a:sym typeface...

Convert image (jpg) to base64 in Excel VBA?

I need to convert an image inside Excel (or through VBA) to base64 (in the end I will make XML output). How can I do this? Do I need to make a reference to DOM? I´ve been reading this question but it only works for text strings not images... Does anyone have any code that I can see? ...