Re: Copying modules programmatically
Thanks.
I'd hoped that wasn't the answer but it's not a catastrophe
Re: Copying modules programmatically
Thanks.
I'd hoped that wasn't the answer but it's not a catastrophe
Re: Email Notification on file save
You could use some event driven code?
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
EMailAttachments
End Sub
Sub EMailAttachments()
Dim objol As New Outlook.Application
Dim objmail As MailItem
Dim strSubject, strRecipient, strCC As String
Dim arrRecipients()
Dim arrCC()
'VARIABLES
strFullFileName = Application.GetOpenFilename
strSubject = "TEST"
strRecipient = "emailaddress"
'CREATE INSTANCE
Set objol = New Outlook.Application
Set objmail = objol.CreateItem(olMailItem)
With objmail
.To = strRecipient
.CC = strCC
.Subject = strSubject
.HTMLBody = "<B>Bold Text</B>" & "<br> Standard text"
.NoAging = True
.Display
End With
'RELEASE MEMORY
Set objmail = Nothing
Set objol = Nothing
'EFFECTIVELY TRICKING EXCEL - YES HAS BEEN CLICKED
SendKeys "%{s}", True 'SEND THE E-MAIL WITHOUT PROMPTS
End Sub
Display More
Replace "Bold Text" & "Standard Text" with whatever you want to see and substitute the e-amil address of your supplier..
HTH
Re: Email Notification on file save
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
EMailAttachments
End Sub
Sub EMailAttachments()
Dim objol As New Outlook.Application
Dim objmail As MailItem
Dim strSubject, strRecipient, strCC As String
Dim arrRecipients()
Dim arrCC()
'VARIABLES
strFullFileName = Application.GetOpenFilename
strSubject = "TEST"
strRecipient = "emailaddress"
'CREATE INSTANCE
Set objol = New Outlook.Application
Set objmail = objol.CreateItem(olMailItem)
With objmail
.To = strRecipient
.CC = strCC
.Subject = strSubject
.HTMLBody = "<B>Bold Text</B>" & "<br> Standard text"
.NoAging = True
.Display
End With
'RELEASE MEMORY
Set objmail = Nothing
Set objol = Nothing
'EFFECTIVELY TRICKING EXCEL - YES HAS BEEN CLICKED
SendKeys "%{s}", True 'SEND THE E-MAIL WITHOUT PROMPTS
End Sub
Display More
Hi,
I'm trying to adapt some code from Chip Pearson on Copying modules programmatically ( I maintain a suite of Financial Models and want to update common modules this way ). Currently the code only works when the source and target files are both open.
Dim VBComp As VBIDE.VBComponent
Dim FromVBProject As VBIDE.VBProject
Dim ToVBProject As VBIDE.VBProject
Dim FName As String
Dim CompName As String
Dim S As String
Dim SlashPos As Long
Dim ExtPos As Long
Dim TempVBComp As VBIDE.VBComponent
Set FromVBProject = Application.Workbooks("TestFile.xls").VBProject
Set ToVBProject = Application.Workbooks("TargetFile.xls").VBProject
ModuleName = "mdlSecurity"
Display More
The problem arises when I try to set the FromVBProject to any string containing the location
Thanks,
Ian
Re: Index Match with duplicate results
Can you separate the Container & OTR data?
Your formulas are currently finding minimums but they find the first instance regardless of whether it's a container rate or an OTR rate.
Re: How to simplify repetitive task: Insert cell value + Run another macro
You can either define the range rngValues as Sheet6!A5:A10 or
Replace [rngValues] with Sheet6!A5:A10 in the code
Re: How to simplify repetitive task: Insert cell value + Run another macro
Sub SaveToPdf
Dim rngValues as Range
Dim rngR as Range
Set rngValues = Sheet1.[rngValues]
For Each rngR In rngValues
Sheet1.Range("B11").Formula = rngR.Value
Call ThisWorkbook.Run_SaveToPDF_Unit_1
Nexr rngR
End Sub
Display More
Where rngValues is the range name for Sheet6!A5:A10
This will loop through the range running the macro for each of the values.
HTH
Re: Index Match with duplicate results
If you're driving this using formulas then you can reset the ranges in the adjacent cell using offset
It's a beast of a formula but
Quote=INDEX(OFFSET($C$4:$O$4,,MATCH(D27,D8:P8,0),,),,MATCH(D27,OFFSET(D8:P8,,MATCH(D27,D8:P8,0),,),0))
gives you the result you want
Re: renaming an attachment with vba
Code for renaming is ( assuming there's only one file attached and they're from the current directory)
Set outmail.attachments(1) = atmt
strFileName = atmt.Filename ' Get Name Of File Attached
atmt.SaveAsFile strNewFileName ' Save as NewFileName
outmail.Attachments.Add strNewFileName ' Attach the file with a new name
outmail.Attachments.Delete FileName ' Delete the file with the old name
strNewFileName will need to be derived from your userform inputs.
Re: renaming an attachment with vba
Hi sukyb1
Could you save the selected file with the new name before attaching it?
Other than that I believe you'd have to save the attached file under the new name, delete the old attachment and attach the new file which isn't very elegant.
Re: Converting negative decimal degrees to proper degrees, minutes, seconds
Hi Vertigo,
Can you just use the ABS of the value to convert the decimal then restate the negative?
You get Minus 4 Degs 6 Minutes 31.875 Seconds that way
Is a negative coordinate like this just an anti-clockwise movement?
If so then maybe it's more 360 Degrees less 4 Degrees 6 Minutes 31.875 Seconds?
Re: Transpose A List Of Data With A Loop
Assuming your addresses atart in A1
copy this in B1 =INDIRECT("R"&COLUMN()-1+(ROW()-1)*6&"C1",)
and drag acrss and down to suit.
HTH
Re: Vba, Separating Ranges With A Border
There might be more elegant ways but this should do it?
Sub FormatSections()
Dim rngStartCell As Range
Dim intNumCols As Integer
Set rngStartCell = Sheet1.Range("a2")
dblref = Sheet1.Range("a2")
intNumCols = 6
Do While ActiveCell <> ""
'RESET COUNTER
I = 0
Do While ActiveCell.Offset(I, 0) = dblref
Range(rngStartCell, ActiveCell.Offset(I, intNumCols)).Select
dblref = ActiveCell.Offset(I, 0).Value
I = I + 1
Loop
'FORMAT THE RANGE WITH BORDERS
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
'MOVE START POINT
Set rngStartCell = rngStartCell.Offset(I)
rngStartCell.Activate
dblref = ActiveCell.Value
Loop
End Sub
Display More
Hi,
Is there anyway of editing a draft outlook document via Excel?
I have a data file that is populated with data and sent to 56 recipients.
I want to use a standard letter but head it with the persons name.
The letter is too long to create using concatenated text strings and line feeds. I'd also like to keep the formatting, bullet points etc )
Thanks,
P1g5purt
Re: If Link Exists Macro
There might be more elegant ways but this should do it?
Private Sub Workbook_Open()
Dim strLink As String
Dim booCreateLink As Boolean
booCreateLink = True
strLink = "H:\HOME\timc\EXCEL\BAD_DEBT_REPORTS\FY2007\BAD_DEBT_2007.XLS"
arrLink = ActiveWorkbook.LinkSources
If Not IsEmpty(arrLink) Then
For I = 1 To UBound(arrLink)
If arrLink(I) = strLink Then
booCreateLink = False
End If
Next I
End If
If booCreateLink = True Then
'CREATE LINK CODE
End If
End Sub
Display More
HTH,
P1g5purt
Re: Find And Format The First Occurrence Of Each Phrase In All The Tables Of Active Doc
Sorry - didn't see this as a word query
Re: External Variables For Access Query
You can name your ranges using Insert Name Define and selecting the appropriate range.
Just a thought - Have you considered loading all the postcodes into an access table and creating a query to give you what you want?
Re: External Variables For Access Query
Sub QueryDataBase()
Dim strPCTo As String
Dim strPCFrom As String
Dim rngQueries As Range
Set rngQueries = Sheet2.Range("Queries") ' Your list of post codes to be queried
For i = 1 To rngQueries.Rows.Count
strPCFrom = rngQueries(i, 0) 'Assuming your list of queries is in two columns From, To
strPCTo = rngQueries(i, 1)
Range("F9").Select
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DBQ=C:\DOCUMENTS AND SETTINGS\ROSS8\MY DOCUMENTS\london_sector_time_distances_access97.mdb;DefaultDir=C:\DOCUMENTS AND SETTINGS" _
), Array( _
"\ROSS8\MY DOCUMENTS;Driver={Driver do Microsoft Access (*.mdb)};DriverId=281;FIL=MS Access;MaxBufferSize=2048;MaxScanRows=8;Pag" _
), Array("eTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;")), _
Destination:=Range("F9"))
.CommandText = Array("SELECT Time_Distance.`From`, Time_Distance.To, Time_Distance.Time" & Chr(13) & "" & Chr(10) & "FROM Time_Distance Time_Distance" & Chr(13) & "" & Chr(10) & "WHERE (Time_Distance.From=" & strPCFrom & ") AND (Time_Distance.To=" & strPCTo & ")" & Chr(13) & "" & Chr(10) & "ORDER BY Time_Distance.Time")
.Name = "Query from DP_2"
.Refresh BackgroundQuery:=False
End With
'COPY THE RESULT
Range("F9").Copy
rngQueries(i, 2).PasteSpecial Paste:=xlValues
Next i
End Sub
Display More
Try this. I've not been able totest it since I've not access to ACCESS presently.
HTH,Ian
Re: Median Blanks Array
Confession time - I'm as baffled as you are - Excel should exclude empty cells, blanks & text from a MEDIAN calc for arrays.
Re: Median Blanks Array
Think I may have missed your point.
You want the array formula to treat the empty cells properly i.e ignore them?
As a workaround you could put spaces in or type "Blank"