missing DwgThumbnail.ocx, but not sure if I need it?

missing DwgThumbnail.ocx, but not sure if I need it?

Gh_man
Advocate Advocate
674 Views
4 Replies
Message 1 of 5

missing DwgThumbnail.ocx, but not sure if I need it?

Gh_man
Advocate
Advocate

I have a massive legacy Excel file, that when I print, gives me an error: "MISSING: AutoCAD DwgThumbnail control module".

 

I hit ok, and it successfully prints. A little research tells me that it's looking for DwgThumbnail.ocx, which I don't have.

 

My questions then, are:

 

1) What does this file do? I'm wondering if I actually need it, since my spreadsheet seems to be working ok, other than the hassle of error messages.I don't see any objects in the file that are obviously taken from CAD, although perhaps they are non-fuctional due to the missing OCX? I can get rid of the message by unloading the reference to it in VBA, but I don't want to just remove a symptom while ignoring a bigger problem.

 

2) If I do need it, where can I get it? From browsing these forums I see that it's an ADN developer file, and I'm not a member of ADN.

 

thanks!

0 Likes
675 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

Are running VBA inside Excel, or inside AutoCAD? When you say "print", do you print Excel sheet data or print AutoCAD drawing (from AutoCAD)?

 

Assume you use VBA code in Excel to automate AutoCAD to print drawing files, and the VBA code in Excel shows a form. Then, it is likely, the form has a drawing preview control: DwgThumbnail.ocx. This is an COM control that has to be registered in the computer. If is used to show a very rough bitmap image of the drawing file as preview, if a *.dwg file name is passed to the control.

 

This control is very old, and I am not sure if you can still find it on the Internet. If you can, simply copy to the computer's HD somehwere and register it with regsvr32.exe. You can also remove it from your Excel VBA project, if previewing drawing file before printing is not a "must-have" thing.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

Gh_man
Advocate
Advocate

I probably should have explained the problem in more detail:

 

When I'm using the excel sheet, and attempt to print anything on that sheet (including a single empty cell) VBA pops up, and gives me a "Compile error: can't find project or library." This occurs in the middle of a subroutine that adds a footer to each page, the footer showing the filename, path, and date. If I hit the stop/reset button in VBA, the printing then proceeds - despite my having stopped VBA! - with the footer present on the printed sheet!

If I then go to Tools, References in VBA, I can see the missing OCX file listed.

 

In case it's relevant, the code it stops at is:

    Private Sub Workbook_BeforePrint(Cancel As Boolean)

      ActiveSheet.PageSetup.LeftFooter = "&8" & UCase(ActiveWorkbook.FullName) & " - Printed: " & "&D" & " - Time: " & "&T"

and it stops at the UCase command. (I'd just remove the upper case conversion, but doing so results in a false path and filename - which is totally baffling - although it also stops the error from coming up!

 

Are CAD thumbnails the only things the OCX affects? So far as I can see, there are no CAD drawings present anywhere on the sheet. (The only drawing I can see looks like it was derived from CAD, but I suspect is now a picture object, since when I click on it the Format tab of the ribbon adds the words "picture tools" above the tab.

 

(Mind you, something wonky may be going on - when I paste a CAD object into Excel, the CAD object shows "drawing tools", but double clicking the object gets me the message "Cannot start the source application for this object. Which is surprising, given that I'm working with almost-fresh installs of both Excel and AutoCAD.)

Thanks!

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor

When a "missing library..." happens in a VBA project and the VBA code runs, the codo execution could stop at any line, not necesary the line where the missing reference being referred to.

 

If you click VBA menu "Debug->Compile xxxxx", VBA will find where the offending line of code is.

 

In your case, the VBA project in Excel likely had a Userform and had DwgThumbnail.ocx control on it; and for somereason the formwas not used or removed. While the form and its related code is removed, the reference may still there.

 

So, you need firstly execute "Debug->Compile ...." to make sure there is no faulty code. Once the compiling passed )and no references in the code to DwgThumbnail, then you can remove the missing reference to DwgThumbnail.ocx.

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5

Gh_man
Advocate
Advocate

Thanks for the info!

 

When I do a Debug->Compile, VBA errors at two locations:

 

The previously mentioned line:

  ActiveSheet.PageSetup.LeftFooter = "&8" & UCase(ActiveWorkbook.FullName) & " - Printed: " & "&D" & " - Time: " & "&T"

 

Plus one other line:

    Selection.Characters.Text = ".125" & Chr(10) & "" & Chr(10) & ".100" & Chr(10) & ".100" & Chr(10) & "0"

 

...neither of which seem to reference CAD! I suspect I could get rid of the latter line completely, because the subroutine it's in appears similar in name and fuction to another sub we use, but I don't know of a way to test if it's in use somewhere.

 

Commenting out both lines gets rid of the error message, but also removes their functionality.

 

That said: doing research, I found this link https://newtonexcelbach.wordpress.com/2014/03/08/problems-with-ucase-and-lcase-in-vba/ that claims that these are red herrings. According to the link, missing references do something that breaks VBA and can cause string manipulation commands to fail. Thus the two lines that cause errors are most likely fine, they are just having problems as a side effect to the missing reference.

 

So the question then: since if I comment out those two lines, the compiler works and doesn't provide any warnings, depsite the still-missing reference, can I assume that the reference is un-needed? Keeping in mind that I don't know what the warning would look like if the OCX *was* required, and that I don't plan to have those lines commented out when I use the sheet for real, as opposed to testing.

 

On a somewhat-related note, another forum post dealing with this problem suggests changing Ucase to VBA.Ucase, and sure enough, that stops the error, (not being a VBA programmer, I have no idea why), but I assume that it only masks the problem, since it doesn't address the missing reference.

 

Thanks!

0 Likes