Log in

View Full Version : VBA6.dll and macros not running...



Jinky Julie
04-22-2009, 12:08 PM
I am very frustrated... :banghead: I work very hard at learning VBA and getting things to work... get them working and !!!... "File not found VBA6.dll" and everything stops... I cannot seem to find any information about this error... anywhere...

VBA6.dll is where it supposed to be... even got new copies from elsewhere... the appropriate References are checked in the editor... I am lost...

I am thinking that it may be me.... maybe I am putting code in the wrong places, or my variable scope is wrong...:dunno

I have experience this with Excel as well when playing with its VBA...

I am looking to you guys to give me a definitive answer to my woes...

XP, Office 2003... all updates are current...

Thanks as always....

Julie.....

fumei
04-22-2009, 12:20 PM
With some actual code to look at...how could we tell if anything is out of scope? Although the error does not really look like a scope error.

In any case, with the information you gave, I am sorry, but I do not think we can help you. I am wondering about:

"even got new copies from elsewhere..."

Hmmm, if you got a new copy of VBA6.DLL, did you properly register it? The file may be there, but if it is not registered.....

Jinky Julie
04-22-2009, 12:34 PM
Hi again Fumei...

Here's the code... It is all held in a separate template. It does (did :confused2 ) work... (I know it ain't pretty... please recall... I am an amateur...)

That dll in not registrable... I have been having this problem for awhile...

I realize that this may be above and beyond... but no one seems to have an answer.... and out in WWW land... it seems to be a common problem... I seem to remember seeing once that it may have had something to do with conflicts with other Word components (templates, etc...) I dunno.... I am at a loss...

Thanks for ANY help.... you can offer...

Julie....






Sub OpenForm()

frmPickDate.Show

End Sub

Private Sub Document_Open()

ThisDocument.OpenForm

End Sub


Private Sub CommandButton1_Click()

Dim oDoc1, oDoc2, oDoc3 As Document
Dim path1, path2, path3 As String
Dim oVars As Variables
Dim WholeDate As String
Dim i, x, y As Long

WholeDate = ComboBox1.Value & ComboBox2.Value & ComboBox3.Value

path1 = " C:\Test\banana1.doc"
Set oDoc1 = Documents.Open(path1)
With ActiveDocument
Set oVars = oDoc1.Variables
oVars("oDate").Value = WholeDate
For i = oDoc1.Fields.Count To 1 Step -1
With oDoc1.Fields(i)
If .Type = wdFieldDocVariable Then .Update
End With
.PrintOut Copies:=4
.Close wdDoNotSaveChanges
Next i
End With

path2 = " C:\Test\banana2.doc.doc"
Set oDoc2 = Documents.Open(path2)
With ActiveDocument
Set oVars = oDoc2.Variables
oVars("oDate").Value = WholeDate
For x = oDoc2.Fields.Count To 1 Step -1
With oDoc2.Fields(x)
If .Type = wdFieldDocVariable Then .Update
End With
.PrintOut Copies:=14
.Close wdDoNotSaveChanges
Next x
End With

path3 = " C:\Test\banana3.doc"
Set oDoc3 = Documents.Open(path3)
With ActiveDocument
Set oVars = oDoc3.Variables
oVars("oDate").Value = WholeDate
For y = oDoc3.Fields.Count To 1 Step -1
With oDoc3.Fields(y)
If .Type = wdFieldDocVariable Then .Update
End With
.PrintOut Copies:=6
.Close wdDoNotSaveChanges
Next y
End With

appWord.Quit wdDoNotSaveChanges
Set appWord = Nothing

End Sub


Private Sub UserForm_Initialize()

Dim arrayDay()
Dim arrayMonth()
Dim arrayYear()

arrayDay() = Array("1 ", "2 ", "3 ", "4 ", "5 ", "6 ", "7 ", "8 ", "9 ", "10 ", "11 ", "12 ", "13 ", "14 ", _
"15 ", "16 ", "17 ", "18 ", "19 ", "20 ", "21 ", "22 ", "23 ", "24 ", "25 ", "26 ", "27 ", "28 ", "29 ", "30 ", "31 ")

arrayMonth() = Array("January/janvier ", " February/février ", "March/mars ", " April/avril ", _
" May/mai ", "June/juin ", " July/juillet ", " August/août ", "September/septembre ", _
" October/octobre ", "November/novembre ", " December/décembre ")

arrayYear() = Array("2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", _
"2017", "2018", "2019", "2020")

ComboBox1.List = arrayDay()
ComboBox2.List = arrayMonth()
ComboBox3.List = arrayYear()

End Sub

fumei
04-22-2009, 02:45 PM
Aaacck!

Hmmmm. OK, I am not sure where you getting your error, as you do not say. However, I am confused at a number of points.

This is code being executed from Word - the use of Document_Open shows this - so why is there
appWord.Quit wdDoNotSaveChanges
Set appWord = Nothing
Where does appWord come in??

You do not really need the Sub OpenForm()


Private Sub Document_Open()

frmPickDate.Show

End Sub will do nicely.

It is good that you are using Document objects. This is good. However, does
path1 = " C:\Test\banana1.doc"
Set oDoc1 = Documents.Open(path1)
actually work for you? I am wondering about that space at the start of the string.

I personally do not to use counters unless I have to. I would replace:
For y = oDoc3.Fields.Count To 1 Step -1
With oDoc3.Fields(y)
If .Type = wdFieldDocVariable Then .Update
End With
with:

Dim oField As Field

.....other stuff

For Each oField In oDoc3.Fields
If oField.Type = wdFieldDocVariable Then OField.Update
Next oField

I am also wondering about:
path3 = " C:\Test\banana3.doc"
Set oDoc3 = Documents.Open(path3)
With ActiveDocument
Set oVars = oDoc3.Variables
oVars("oDate").Value = WholeDate
For y = oDoc3.Fields.Count To 1 Step -1
With oDoc3.Fields(y)
If .Type = wdFieldDocVariable Then .Update
End With
.PrintOut Copies:=6
.Close wdDoNotSaveChanges
Next y
End With
the .Close applies to the ActiveDocument - oDoc3 is still open. Is this really what you want?

Finally, WHERE are you getting this VBA6.DLL error??? Does the whole thing not execute? It executes at first, then crashes at some point? In which case...at what point?

fumei
04-22-2009, 03:02 PM
As a general help you may want to explore how arrays work, a bit more. You have that long list of strings to get 1 to 31 for your arrayDate. (BTW: please try and use the underscore character when posting long strings...it breaks up the code lines and makes it easier to read.)

Here is an alternative.
Dim arrayDate()
Dim j As Long
For j = 1 To 31
ReDim Preserve arrayDate(j)
arrayDate(j) = j
Next

ComboBox1.List = arrayDate

Jinky Julie
04-22-2009, 04:48 PM
Fumei...

I guess the "Aaacck!" was deserved... I know, I know... but I am just learning thanks to you and everyone here... (I am glad you didn't see my other one... boy, I know that's inefficient... I'd love someone to clean that mess up... but I am proud of it... for a first try...:clever:)

It stops at the form initialize (at least that's where the debugger stops and highlights)...

OK... here's the story... this little piece of joy was to help my co-workers. They have to open three documents (separately), change the date on each, and print each. Just thought I'd try to make it faster for them... I am trying to just open the form, choose the date and off we go...

• appWord... just wanted to close Word down completely when everything was said and done... is there a better way??

• Sub OpenForm() - OK... I'll get rid of it

• Not sure where the space in the string came from... but it did work...

• I tried adapt (newbie) this code I found without the counter, but no joy... I'll try your way...

• ActiveDocument & .Close - I though I should close each document before I moved on... maybe not (????)

• The long string was an inadvertant error on my part... sorry... I researched and struggled with the arrays... I tried everything I found... this was the only thing that worked for me... I will try your suggestion...

As mentioned... it shows the File not found VBA6.dll and the debugger highlights the UserForm_Initialize() subroutine...

Thanks for your time and patience...

Julie....

fumei
04-23-2009, 08:53 AM
Ooops, my mistake. You are correct. Once you use:

Set oDoc3 = Documents.Open(path3)
With ActiveDocument
oDoc3 IS the ActiveDocument. So yes, it does close oDoc3. This is perhaps a reason why it is better - when using objects - to fully use them. By that I mean:
Set oDoc3 = Documents.Open(path3)
With oDoc3 ' instead of ActiveDocument



"• appWord... just wanted to close Word down completely when everything was said and done... is there a better way??"

Huh? But you are in Word. You can not use appWord unless you have declared it as an application object. Where do you do that...and why?

I do not know why you are getting the error. I have full capability using VBA, and I just did a full search for VBA6.DLL, and I do not have one at all. So, frankly, I am lost. I too have been searching across the 'Net regarding this, as it seems almost common, but I am no further ahead than you are. I just do not know.

I do not have a file VBA6.dll...yet I have no problems with VBA. I simply do not know what is happening.

fumei
04-23-2009, 09:18 AM
Interesting. BOTH of the following DLL files are, supposedly, for the VBA Development Environment.

Vba332.dll 1559KB, Visual Basic for Applications Development Environment - Microsoft Corporation

VBA6.DLL 1656KB, Visual Basic for Applications Development Environment - Microsoft Corporation

I do have Vba332.dll.

I do NOT have VBA6.dll

I have no idea what that means.