Archive

Posts Tagged ‘vba’

MS Access: HTML Editor control to use in forms

February 10th, 2011 5 comments

If you want to get HTML editor within MS Access form, there are couple of solutions available. The free solution I know is to get Not So Elegant HTML Editor. The problem with this editor is that

  • After looking at this editor, you will never say “so cool”
  • It is good for basic editing but many important functionality like “Table” editing is missing.

When I had to create HTML Editor within MS Access form, I asked the question to myself “Why to reinvent the wheel?” and the solution I came up with has the main benefits

  • It is completely FREE
  • When users will look at it, they will definitely say “so cooooool”.
  • Rich feature set
  • XHTML compliant code will be generated and hence output can be used anywhere.
  • Plugin based architecture can help add extra cool features

Here is a sample of how this editor would look like Read more…

MS Access VBA: Get/set Javascript Variable in Microsoft Web Browser ActiveX Control

February 5th, 2011 1 comment

In your MS Access application, if you are using Microsoft Web browser, we may have to interact with the Javascript variable inside the loaded page. There is no obvious method exists in the Web browser control but using the following trick you can get/set the Javascript variable in the webpage.

Quick Tip:

Add Javascript function to get/set the value of Javascript variable/ HTML element from/to the hidden field. Execute the function using VBA code with the help of DOM functions available in VBA. Please read further for the details or download the code. Read more…

Change MS Access application title and icon using VBA

December 15th, 2009 No comments

Here is a code to change MS Access application title and icon using VBA. This code also sets the application icon as form and report default icon.

Dim db As Database
Set db = CurrentDb
db.Properties("AppIcon").Value = CurrentProject.Path & "\Bee.ico"
db.Properties("AppTitle").Value = msgMainTitle
db.Properties("UseAppIconForFrmRpt").Value = True
Application.RefreshTitleBar

Click here for list of all properties exposed by CurrentDB.Properties().

Categories: MS Access Tags: , ,

ADODB Command.Execute does not return error for RAISERROR

December 4th, 2008 No comments

Description:

I was executing a stored proc which would halt its execution using RAISERROR. When I tried to run the stored proc in Query Analyzer it worked fine and gave me error but in VBA it couldn’t halt the execution and continued to the next statement. Read more…

Categories: MS Access Tags: , , ,

MS Word: Remove watermark from all Word pages using VBA

March 28th, 2008 6 comments

You can create watermark in MS Word document by going to Format Menu > Background > Printed Watermarks… Here you will be able to set Text Watermark in each page. Now if you want to remove the watermark from all pages, use the following VBA script.

   Dim section As Word.section
   Dim pheadertype As Long
   Dim hdr As Range
   Dim sp As Shape
   Dim str As String
   For Each section In ActiveDocument.Sections
      With section
         Set hdr = .Headers(wdHeaderFooterFirstPage).Range
         For Each sp In hdr.ShapeRange
            str = sp.Name
            If InStr(str, "PowerPlusWaterMarkObject") > 0 Then
               sp.Visible = msoFalse
             End If
          Next
          Set hdr = .Headers(wdHeaderFooterPrimary).Range
          For Each sp In hdr.ShapeRange
             str = sp.Name
             If InStr(str, "PowerPlusWaterMarkObject") > 0 Then
                 sp.Visible = msoFalse
             End If
           Next
       End With
    Next