PDF Creator

Just wanted to post about a great software that I am using to print from excel using vba to a pdf file. Adobe Acrobat was too messy, and cost a bomb. However PDF Creator is an open source project developed in vb which is quite cool. It is still a bit buggy, but is great work. If anyone is looking to contribute, look up the site of the developers.

Solving the “The Invoked Object has disconnected from its clients” error in Excel VBA

This error may be common in other situations too but I had to spend an hour getting to solve it and wanted to put it up for someone else who needs it.

A screen shot of the error is below

My code quite simply does the following

1. Embeds 3 pdfs into a sheet
2. Creates 3 buttons
3. Sets up the code so clicking the button opens the pdf file.

Here is the code that was generating the error

For i = 1 To 3
'add ole object
OLEFileString = PDFPath & "sheet" & Trim(Str(i)) & ".pdf"
wbtarget.Sheets(2).OLEObjects.Add(Filename:=OLEFileString, link:=False, displayasicon:=True).Select
'add button
wbtarget.Sheets(1).OLEObjects.Add ClassType:="Forms.CommandButton.1", _
Left:=126, Top:=96 * i, Width:=126.75, Height:=25.5
'Code for button
code = ""
code = "Sub CommandButton" & Trim(Str(i)) & "_Click()" & vbCrLf
code = code & "Dim OleOle as OLEObject" & vbCrLf
code = code & "Set OleOle = Sheet2.OLEObjects(" & Trim(Str(i)) & ")" & vbCrLf
code = code & "OleOle.Activate" & vbCrLf
code = code & "End Sub" & vbCrLf
'Write code for button
With wbtarget.VBProject.VBComponents("Sheet1").CodeModule
.InsertLines .CountOfLines + 1, code
End With
DoEvents
Next i

Just to clean up the interface, I added the pdf files on a separate sheet. So this code wasn’t working. From a few forums, I tried to add a wait through Application.Wait (Now + TimeValue("0:00:02")) but it didn’t solve the error.

Finally it seems to have something to do with the inner workings which is not documented or buggy or both. Apparently after adding the code to the module, the object interface is closed for the worksheet. Simply adding the code generation to a separate loop fixed the problem.


For i = 1 To 3
'add ole object
OLEFileString = PDFPath & "sheet" & Trim(Str(i)) & ".pdf"
wbtarget.Sheets(2).OLEObjects.Add(Filename:=OLEFileString, link:=False, displayasicon:=True).Select
'add button
wbtarget.Sheets(1).OLEObjects.Add ClassType:="Forms.CommandButton.1", _
Left:=126, Top:=96 * i, Width:=126.75, Height:=25.5
Next i
For i = 1 To 3
code = ""
code = "Sub CommandButton" & Trim(Str(i)) & "_Click()" & vbCrLf
code = code & "Dim OleOle as OLEObject" & vbCrLf
code = code & "Set OleOle = Sheet2.OLEObjects(" & Trim(Str(i)) & ")" & vbCrLf
code = code & "OleOle.Activate" & vbCrLf
code = code & "End Sub" & vbCrLf
'Write code for button
With wbtarget.VBProject.VBComponents("Sheet1").CodeModule
.InsertLines .CountOfLines + 1, code
End With
DoEvents
Next i

It now works perfectly! If you have any suggestions or questions, please comment.

Getting Skype to work on intrepid ibex with video

I have a logitech quick cam express web cam and a cheap microphone I picked up at nehru place. I installed skype from the repos and neither the audio nor the video would work. Chats worked fine though. So began trying to get them to work.

I decided I would get the latest deb version from the skype website and work with that. You can get the deb package or other packages from here.

During install I am warned that it is better to keep the older version from the repository itself, but I go ahead and install the new version.

I still have no luck and the test video in video options of skype shows a green noise, with no audio input.

Audio Input Setup

First the Audio. Make sure that your alsa mixer settings are proper. You could try recording with the sound recorder or audacity to ensure that your microphone is plugged in right.

Then in the Audio options in Skype set the Audio input device (Sound in) to the hardware device. For me it is HDA Intel (hw:Intel,0). Sound Out and Ringing should be set to pulse audio.

Go ahead and do a test call from the main skype window. You should now have audio. If not, try changing the sound input to various values, applying and then testing.

Video Setup
This seems to a common problem with Skype on Intrepid Ibex. I got the workaround from a thread on Ubuntu Forums.

We begin based on a tutorial by Howard Shane.

Since this is Ubuntu, we are assuming the USB device is already mounted and ready to go. However we can check by
$ lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 046d:0928 Logitech, Inc. Quickcam Express
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 045e:0084 Microsoft Corp. Basic Optical Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In my system, it shows the camera on the second line. Your camera should be detected too.

Once you are sure that your camera is up and running, you can install cheese to see if the cam works.

$ sudo aptitude -y install cheese
$ cheese

Start the Video playback and ensure that your camera is online.

Ok, now we only have to configure skype to startup differently.
$ sudo gedit /usr/local/bin/skype

Paste the following lines into the file
#!/bin/bash
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/skype

Then make the file executable.
$ sudo chmod a+x /usr/local/bin/skype

Skype now works fine with video too. To test, open skype options and select the video section. Select the appropriate camera (there usually should be only one) and click the ‘test video’ button on the top right. If everything is ok, then the button will be replaced by the video.