5

I have problem with File System Object late binding. This is my code:

Dim WordA As Object 'aplikacja programu Word
Dim PlikW As Object 'plik Worda
Dim Nazwa As Object 'obszar Worda ze zdefiniowaną nazwą
Dim Zakres As Range 'zakres danych używany do wiadomości
Dim NrRaportu As Integer 'Numer tworzonego raportu
Dim Katalog As String 'pełna nazwa katalogu, w którym zapisywane są wiadomości
Const Raport_szablon = "Raport_szablon.docx" 'zazwa pliku z szablonem
Dim fso As Object 'Objekt FileSystemObject

'1. Wczytanie danych
Set Zakres = Range("R2:Z" & Cells(Rows.Count, "R").End(xlUp).Row)
Katalog = ThisWorkbook.Path & "\Raporty"
Set fso = CreateObject("FileSystemObject")
If Not fso.FolderExists(Katalog) Then _
    fso.CreateFolder (Katalog)

and I get a message that

"ActiceX component can't create object"

.

9
  • 1
    Possible duplicate of How do I use FileSystemObject in VBA? Commented May 11, 2018 at 20:55
  • 8
    You need Set fso = CreateObject("Scripting.FileSystemObject") rather than simply Set fso = CreateObject("FileSystemObject") Commented May 11, 2018 at 21:00
  • 1
    Put Option Explicit on top to learn why. Commented May 11, 2018 at 21:12
  • 3
    @JohnColeman Apparently not (although it's not the culprit here). Commented May 11, 2018 at 21:17
  • 1
    @GSerg Interesting. Learn something new every day. Commented May 11, 2018 at 21:34

1 Answer 1

0

You need also to use the reference manger and add the dll / ocx to the project. c:\windows\system32\wshom.ocx if i remember right

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.