I am trying to get the Mime Type of an uploaded files. For doing this, I have the following code:
Public Function GetMimeType(ByVal File)
Dim oMimeMap
Dim vntMimeType
Dim avntMap()
Dim DotPos
Dim Extension
Set oMimeMap = GetObject("IIS://LocalHost/MimeMap")
I, however, get the following error:
Microsoft VBScript runtime error: Permission denied: 'GetObject'
Can someone please help me what is incorrect?
Related
I need to copy one module (Dictionary from Tim Hall - https://github.com/timhall/VBA-Dictionary) from one workbook to another programatically. For this I am using this piece of code:
Sub CopyMacrosToExistingWorkbook(SourceWB As Workbook, strModuleName As String, TargetWB As Workbook)
Dim SourceVBProject As VBIDE.VBProject, DestinationVBProject As VBIDE.VBProject
Set SourceVBProject = SourceWB.VBProject
Set DestinationVBProject = TargetWB.VBProject
Dim SourceModule As VBIDE.CodeModule, DestinationModule As VBIDE.VBComponent
Set SourceModule = SourceVBProject.VBComponents(strModuleName).CodeModule
Set DestinationModule = DestinationVBProject.VBComponents.Add(SourceModule.Parent.Type)
DestinationModule.Name = strModuleName
With SourceModule
DestinationModule.CodeModule.AddFromString .Lines(1, .CountOfLines)
End With
End Sub
On Windows everything is going well but on Mac (Office 365 version 16.29), the file, where I will import this Dictionary modul is not working. It cant be saved and it writes this Internal error to me:
The interesting thing is, that it is enough to copy this broken file to windows, open it, save it and return it back to Mac. But this is not sufficient solution to me.
I Have found, that if I will remove from Dictionary class module this piece of code, the "Internal Error" is not showing, but I cant use the module without this code:
Public Enum CompareMethod
BinaryCompare = VBA.vbBinaryCompare
TextCompare = VBA.vbTextCompare
DatabaseCompare = VBA.vbDatabaseCompare
End Enum
So I guess, that something its wrong with this Enum class. What or where could be the problem? I cant find it. Thanks for any help.
It is a long shot, but have you tried using Excel 16.28?
I have several macros that worked fine since 16.12, but after upgrading to 16.29 I got some errors and I couldn't understand what was wrong with the code.
I reverted to 16.28 and all good again.
I'm trying to open a MathCAD application using excel VB code. But I'm getting a runtime error "-2147220992 (80040200)". I have an indication as Automation error. Add your comments to solve this.
Dim eWS As Mathcad.Worksheet
Set eApp = CreateObject("Mathcad.Application")
eApp.Visible = True
Path = "C:\Desktop\Test.xmcd"
Set eWS = eApp.Worksheets.Open(Path)
I am trying to automate my PCOMM login process. When I execute the below piece of code, I am getting an error.
Dim Num as Long
Set autECLConnList=
CreateObject("PCOMM.autECLConnList")
autECLConnList.Refresh
The error I got is "ActiveX component can't create object." in line 2. I even checked whether the dll was missing, but it looks fine.
According to the documentation, it appears you need to create the object before initializing it:
Dim autECLConnList as Object
See here: https://www.ibm.com/support/knowledgecenter/en/SSEQ5Y_13.0.0/com.ibm.pcomm.doc/books/html/host_access08.htm
Dim autECLConnList as Object
Dim Num as Long
Set autECLConnList = CreateObject("PCOMM.autECLConnList")
autECLConnList.Refresh
Num = autECLConnList.Count
Num is the number of connections present in the autECLConnList collection for the last call to the Refresh method and The Count property is a Long data type and is read-only.
Following from my previous question, I am now struggling to create a working Application.CountIf function. I am using the following code to access the file as "xl0":
'DATABASE ACCESS
Dim xl0 As New Excel.Application
Dim xlw As New Excel.Workbook
Dim db_directory As String
db_directory = "R:\New Quality Management System\xls\Supplier\Non-Conformance\Supplier Non-Conformance Database.xlsm"
Set xlw = xl0.Workbooks.Open(db_directory)
I can create a function to search the same open document no problem...
Test = Application.CountIf(Range("B:B"), Report_ID)
MsgBox (Test)
...but neither of the methods I've tried for searching in the document open in the background have worked...
Test = Application.CountIf(xlw.Sheets("SNCR Log").Range("B:B"), Report_ID)
...and...
Test = xlw.Sheets("SNCR Log").Application.CountIf(Range("B:B"), Report_ID)
What am I missing?
Just a guess, did not test it, but as Application refers to your current open application and you want to search within the xl0 application try
xl0.CountIf(...)
and see if that helps.
I have got this error at:
Dim frmD as frmDocument
I am using VB 6.0 under windows XP, Can please any body tell me which reference should i need to add?
this is exact code:
Private Sub LoadNewDoc()
Static lDocumentCount As Long
Dim frmD As frmDocument // at this line i got error, User defined type not defined
lDocumentCount = lDocumentCount + 1
Set frmD = New frmDocument
frmD.Caption = "Document " & lDocumentCount
frmD.Show
End Sub