I made a VBA Project with 2 userforms in a verison of Office 365. But after an recent update (new computer with new installation of Office) the userforms cant be loaded. I have not been able to spot the diffrence between the Excel versions as all the versionnumbers match eachother.
I thought it was a problem with the datepicker control but error presistes even after that control is removed. I have also verified that Excel is of 32 bit verison on both computers
Option Explicit
Public Sub Menu() <-Shortcut runs this
UserForm2.Show
End Sub
Private Sub UserForm_Initialize() <-Userform2 Initializes
Set UF = New UserForm1 <- Error
Do stuff in UserForm2
End Sub
When the datepicker control was in the UserForm1 the error recived was:
Could not read some objects since they are´nt availible on this computer
Followed by
Complie error in hidden modul UserForm1.
Error usally shows when the code is incomapitble
with the app version, platform or architecture.
These are the reference for the Project:
VBA
Excel 16 Obj. Lib.
OLE Automation
Office 16 Obj. Lib.
Forms 2 Obj. Lib.
Common Controls-2 6.0 (SP6)
My knowledges limt has been reached as I thought that this is was 64 bit issue. If I remove the datepicker control from UserForm1 it only shows the second error.
If you google for it you will find e.g. this:
Download the MSCOMCTL.ocx in Microsoft Download.
On search menu / Cortana search command prompt and run it as administrator by right clicking it.
Copy the MSCOMCTL.ocx file to C:\Windows\SysWOW64.
Navigate the command prompt to the location C:\Windows\SysWOW64 and type regsvr32 mscomctl.ocx.
Do regsvr32 both mscomctl.ocx and mscomct2.ocx
Related
I can writing VBA in Mac os. The below code in excel (windows) check an option button.
ActiveSheet.Shapes("Otion button 1").OLEFormat.Object.Value=true
This code does not work in Mac excel.
Can anyone help to get the code for Mac excel to do this function.
Thank you,
The code you pasted doesn't work in the Windows environment either. It results in an error: "Runtime error '438': Object doesn't support this property or method"
After exploring the locals window, I found that the correct way to access this value is through a double .object ... So your code would be:
ActiveSheet.Shapes("Otion button 1").OLEFormat.Object.Object.Value = True
I am running Excel 2016, which may be relevant if the below is a compatibility issue...
In short, I am trying to display a PDF, embedded in a UserForm in Excel.
I have a UserForm, say UserForm1.
I have enabled the following extra references:
Microsoft Visual Basic for Applications Extensibility 5.3
Adobe Acrobat Browser Control Type Library 1.0
This allows me to add the Adobe PDF Reader as an "Additional Control"
The control appears as a hatched box icon (bottom left), which I'm not sure it's meant to. Then if I try to add one of these objects to UserForm1 (both programmatically and in design view) it gives me an error
Element not found
For reference, the relevant lines of VBA I was using were:
Dim PDFviewer As AcroPDF
Set PDFviewer = PDForm.Frame1.Controls.Add("AcroPDF.PDF.1")
Which I took from this Adobe forums thread: https://forums.adobe.com/thread/1065554
Resources online suggest it might be that the AcroPDF control is no longer supported. If so, is there another way to achieve what I want?
As an alternative to using the AcroPDF, try using the WebBrowser Object.
It requires including the additional control
Microsoft Web Browser
Add a WeBrowser on the UserForm named WebBrowser1
Private Sub UserForm_Click()
Me.WebBrowser1.Navigate "about:blank"
Me.WebBrowser1.Document.write "<HTML><Body><embed src=""C:\temp\SO_Answers\test.pdf"" width=""100%"" height=""100%"" /></Body></HTML>"
End Sub
You can just .Navigate to the PDF directly, but, to quote my comment:
"It's safer to use the html part, depending on the machine settings, sometimes direct navigation will initiate download instead of display."
So I have been able to load a PDF into my userform (Excel 2013 on all machines) setting reference Adobe Acrobat Webrowser Control and adding control to userform. When i open the file on another computer or try to create another excel userform and pdf I get the following errors "Run-time error-459" or "Element not found" or "Compile error: Method or data member not found"
I am using Acrobat Adobe Reader DC
I also noticed when adding control to form it labels it as Control1 instead of AcroPDF1
Private Sub Workbook_Open()
With UserForm1.Control1
.LoadFile ThisWorkbook.Path & "\sample.pdf"
End With
UserForm1.Show
End Sub
Please any help much appreciated
Make sure that the Additional Control for Adobe has been added. Also take a quick look into this post for workaround and suggestions. http://www.ozgrid.com/forum/showthread.php?t=88177
After some trial and error i found a solution. I was currently using google chrome when experiencing this issue. The problem was that i had a google app conflicting with the pdf. So i disabled google apps and problem dissappeared. Sorry comunity i didnt resopnd earlier..thanks for all the input
I am using Visual Studio 2013 Professional and vb.net. When I start a new Windows Form and drag ReportViewer to the blank form, it does not appear on the form. At the bottom, it shows ReportViewer1; however, there is no reportviewer visible. This means I can't attach the viewer to a report or database.
If I start an entirely new project, I can drag the reportVierwer. This is a big project or I would just start a new one and do it.
For some reason (on VS2015) the ReportViewer instance is not added to the Controls collection of the form inside the InitializeComponents method.
Adding this line (reportViewer being the instance of ReportViewer) fixes the problem:
this.Controls.Add(reportViewer);
You can always add it in code behind manually, or to manually edit the designer.
Add the Load event handler to the form to refresh the report viewer on Load:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.ReportViewer1.RefreshReport()
End Sub
And in designer create the ReportViewer instance. In InitializeComponent:
Private Sub InitializeComponent()
Me.ReportViewer1 = New Microsoft.Reporting.WinForms.ReportViewer()
'...
'
'ReportViewer1
'
Me.ReportViewer1.Location = New System.Drawing.Point(13, 13)
Me.ReportViewer1.Name = "ReportViewer1"
Me.ReportViewer1.Size = New System.Drawing.Size(396, 246)
Me.ReportViewer1.TabIndex = 0
'...
End Sub
Friend WithEvents ReportViewer1 As Microsoft.Reporting.WinForms.ReportViewer
It's not ideal solution. When adding to your main code you are mixing presentation and logic. When modifying designer code there is a risk it will be overridden.
Perhaps some improvement would be to create yet another Form partial class where you put the above mentioned code. For instance, as LoadReportViewer method and then invoke the method from your code. This way you do not mingle designer code with logic and you don't risk the change is removed by designer.
Im creating a very simple Windows Phone 8.1 app in Visual Studio Express. I have added a Hyperlink control, then from that I have double click to go to the relevant VB page.
As instructed by the many tutorials out there I have added the code for the button - which should navigate it to the second page I have created.
Private Sub hyperlinkButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
NavigationService.Navigate(New Uri("/SecondPage.xaml", UriKind.Relative))
End Sub
However VB keeps on giving me the error "NavigationService is not declared"
Searching the error message has given me very little joy so far.
In Windows Phone 8.1, code for navigation to another page are declared as,
this.Frame.Navigate(typeof(SecondPage));
You cannot just call the class as you will need to get it from the app (so that the system navigates within the app). This is done by accessing the PhoneApplicationFrame!
It should look something like this:
Private Sub hyperlinkButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Uri uri = New Uri("/SecondPage.xaml", UriKind.Relative);
((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(uri)
End Sub