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
Related
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
I want to use the BeforePrint event in Excel in order to edit the header and footer of the final printout depending on various parameters. In order for the user to check whether the page setup is right, this code needs to be called before the print preview within Excel is shown. When calling the print preview with the VBA code ThisWorkbook.PrintPreview, the event fires before the preview is shown, but when using "Ctrl+P" or "File - print" the event is not called until the document is sent to the printer, so the print preview does not show the final printout. The code Application.CommandBars.ExecuteMso "PrintPreviewAndPrint" also leads to the same unsatisfying result.
I've noticed, that when using ThisWorkbook.PrintPreview the preview is shown in full screen mode while the other methods show the 'normal' print preview. To test if the event is called, I used the following short piece of code.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Debug.Print "BeforePrint"
End Sub
I need a foolproof way of showing the correct print preview, so using a button with the VBA code mentioned above is no option. Any suggestions?
Thanks in advance, mk
Even though you have not disclosed which Excel version you are using (it might be vital in this case). I am afraid that getting .BeforePrint event called before the Printing preview when using Ctrl+P might not be possible in your case since "Excel 2013 and later doesn't run Workbook_BeforePrint on Print Preview." (user OzRoz, 2017)
The above answer is taken from a thread which was asking similar question. In the answer, OzRoz also mentions that "you can get it to run for testing by adding the 'Print Preview Full Screen' icon to your QAT (Quick Access Toolbar)"
Perhaps this provides a definitive answer to your problem.
folks,
i can successfully reach a web page from a UserForm within an Excel workbook and retrieve a website print image using .Navigate; i can even switch to a second web page and retrieve a website print image. but i get a 'script' error, either as i retrieve the first webpage, or as i retrieve the second web page. if i click 'yes' to continue running the script, it proceeds without issue. i don't have sufficient 'debug' experience to follow what is throwing the error. so, if you can help me find the 'root cause', maybe i can fix the error?
this attachment is the error message
the navigate module is here:
Private Sub optCandleChart_Change()
Me.wbSCC.Navigate "http://stockcharts.com/h-sc/ui?s=" & txtTicker1.Value & "&p=D&b=5&g=0&id=t56926565868&r=1501858722627&cmd=print"
End Sub
when the UserForm launches, a ticker is fed from the Excel worksheet to the UserForm in txtTicker1.Value. it works, just hitting 'Yes' to continue running script is a bit tacky. is it because i am not setting up 'Change()' properly?
thanks,
ron
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."