I'm trying to open a pdf file from within excel vba. I have tried using the followhyperlink method but adobe acrobat opens very briefly then immediately closes Code: Sub OpenPDF 'Dim pdf As String On Error Resume Next 'pdf file to open pdf = 'K: PDF mypdf.pdf' 'open the pdf file ActiveWorkbook.FollowHyperlink pdf End Sub So then I tried to create an instance of acrobat by setting a reference to the acrobat object but I can't get this to work either! The code I'm using is Code: Sub OpenPDF Dim pdf As AcroPDDoc Dim strPDF As String Set pdf = CreateObject('AcroExch.PDDoc') 'pdf file to open strPDF = 'K: PDF mypdf.pdf' 'open the pdf file pdf.Open strPDF End Sub Any ideas what could be wrong with either approach?
Newcomers to VBA often confuse VBA’s built-in functions and Excel’s workbook functions. A good rule to remember is that VBA doesn’t try to reinvent the wheel. For the most part, VBA doesn’t duplicate Excel worksheet functions. Aug 23, 2018 - Use VBA add-ins and macros that you developed for Office for Windows. Applies to: Excel for Mac| PowerPoint for Mac| Word for Mac| Office 2016 for Mac. For instructions on creating an installer for your add-in, please refer to the. As web pages Formatting and VBA codes for headers and footers.
Hi, I'd like help in creating a macro that deletes an entire row that has emtpy cells in col B, C & D in the same row. So for example if I have empty cells in b3,c3 & d3 I'd like the row deleted. I've used the code below for just column B but I need to include column C & D as well.
I tried putting Columns('B:D') but it deletes everything. Code: Sub Step4 On Error Resume Next Columns('B:B').SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub I'm sure it's something simple.
Any help much appreciated Wrightie. I am trying to insert a range of cell in the body of an outlook email with the same format. The code I am using now is below and it does insert anything in the email body. Code: Sub Mail Dim OutApp As Object Dim OutMail As Object Set OutApp = CreateObject('Outlook.Application') OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail.To = '[email protected]'.CC = '.BCC = '.Subject = 'Burden Report'.Body = ActiveSheet.Range('A1:D12').Attachments.Add ('C: Documents and Settings cbelcher Desktop Burden Report.xls') End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing Set objMsg = Nothing End Sub.
Hi there, I have a piece of code called ConvertDates that formats data contained on 6 worksheets. The 6 data sheets all contain a data connection to a website of foreign exchange tables. What I want is for my code to execute as soon as the data connection refresh has finished.
When I use the statement Code: ActiveWorkbook.RefreshAll Application.Run 'Project1.xlsm!ConvertDates' The code executes the macro whilst the refresh is still happening, thereby screwing up my results. I don't really want to use a timed wait, because the refresh speed is going to vary from user to user. Is there some way I can tell excel to wait till the refresh has finished and then execute the code? Any help would be hugely appreciated. Hello, As the title goes this is as simple as it gets.
The macro worked good when I was using excel 2003 but now that I have 2007 everything works for except the resizing (Picture.Width & Picture. I am trying to figure out how to write a formula to figure out production cycle time. We will be building 8 'widgets' a day.
We will work 10 hours a day. There is a 20 minute break at 9:20 am. Production shuts down for lunch 30 minutes for lunch at 12:30.
Production starts at 6:00 am. Here is what I can do. Production cycle time = (10.60)-30/8 or 71.25 minutes If we start at 6:00 am, the first scheduled cycle completion time = TIME(6,0,0+) My problem is when I am trying to use a logical 'IF' statement to account for the 20 minute break or lunch and still calculate the end of each cycle time through the day I receive a number of error messages. This is the formula I am trying to make work. I have the cell the formula is in, formatted with a 'mm,ss' format. =(IF(D4+G1/14409:20,(D4+G1)/24,(D4+G1+15)/1440)) I have included an attachment to help (a picture is worth a thousand words).
![Writing vba code in excel Writing vba code in excel](/uploads/1/2/5/6/125614405/232315204.png)
Any help will be greatly appreciated. I have bought a number of books in an attempt to figure this out, and I am still stumped. Thought I'd append my experience of the above problem - you can find all sorts of references to it everywhere. My problem was that a userform defined with Excel at work (containing DT pickers) gave the message in the title when opening it at home.
I had a light-bulb moment and wondered whether there was a difference in the version numbers for MSCOMCT2.OCX at work and at home. Turned out the work version was newer. I then copied the MSCOMCT2.
files from work, made a backup of them at home and copied those from work to my C-drive (Windows XP - c: windows system32 ). I then rebooted the machine - still no luck. Then, finally I unregistered the old DLL via Code: regsvr32 /u c: windows system32 MSCOMCT2.OCX (not sure if this was necessary, but I didn't think it could hurt).
Reregistered the DLL via Code: regsvr32 c: windows system32 MSCOMCT2.OCX and what do you know - it worked. Summa summarum - it could be an idea to check whether the two machines have different version numbers for the MSCOMCT2.OCX files. Hello, i've got the following problem: I want users to double-click on a row on a protected sheet and then do some code based on the row-number of the clicked cell. I've protected the sheet because it contains a lot of formula's.
When a user double-clicks a row it triggers the code through the WorkbookSheetBeforeDoubleClick event. After the code is executed Excel shows a message that the cell that was clicked was protected etc etc. How can I prevent this message from popping up? I've already tried Code: application.displaywarnings = false but that didn't work Thanks. I am looking for the code to select the visible data after applying a data filter. Actually I know how to select the data after applying the data filter but the issue is I am not able to exclude the header row and give the target range as used (non-blank) rows only!! I am using below code to Select the Visible rows in the target range: Code: Range('A:p').SpecialCells(xlCellTypeVisible).Select Problems in this code a 1) after applying the filter, while selecting the data it is selecting all the rows in given range till last row on the workbook.
I need this to select the the data only till the last used row in the given range. 2) It is not possible to provide the address of the first row after we apply the filter since the first row address may change depending on the values in the table. 1st time when I am running the macro the first row in the visible filtered data is starting at Cell address A4 and next time when I will run the macro it may be A6 3) The Code is also selecting the 1st row which is a header row. How can we exclude it from selection. Some one please revert with the solution.
Thanks in advance. I'm trying to use conditional formatting to highlight phone calls that came in between certain hours. The call times are in the custom format h:mm, although it could easily be changed to an Excel time format.
I'm using Excel 2002. I want the cell to have a different fill color if it falls within particular time frames. Example: If the call came in between 22:00 and 23:59 color is light green.
If the call came in between 23:59 and 08:00 the color is yellow. Example spreadsheet is attached. Thanks in advance. Hi, This is a very basic question, but i have been struggling for hours, so I must ask. I I trying to simply fill a combobox on a userform from a named range on a sheet, I want to populate the combobox as soon as the userform starts. (I launch the userform from a button on the sheet) Where must I place the code? And will this code work?
Code: Sub Button1Click Set UserForm1.combobox1.List = Sheets('Sheet1').Range('MyRange') UserForm1.Show End Sub I am very new to vba, so please excuse my ignorance, any help would be greatly appreciated regards jim. Hi All, I have the below code which deletes all items from a listbox and my excel sheet which is the source for populating that listbox. I am using a option button style for my listbox and the selection style as single.i.e. You can select only one item at one go in the lisbox. I want my macro to delete the selected item from my worksheet.i.e. It's entire row so that it doesn't reflect in my lisbox any more.
Below is my code: Code: Private Sub CommandButton2Click 'REMOVE SELECTION Dim I As Long With ListBox1 For I =.ListCount - 1 To 0 Step -1 If.Selected(I) Then.RemoveItem I Sheets('URL List').Rows(I + 2).EntireRow.Delete End If Next I End With End Sub Thanks a lot for your help in advance.