0

I am having a MS Visio diagram. Often I need to export the part of the drawing to a picture file to use it somewhere else, but I am really tired of using menus.

I want to export some selected elements right to .bmp, .img, png, or other picture file without using menus bu with given filepath and defined resolution in pixels per inches.

Selected elements in Visio

After some trials I have found the working VBA code and I am going to share it here.

1 Answer 1

0

My solution to this problem:

Sub ExportSelectionToBMP()
    Dim vsoSelection As Visio.Selection
    Dim vsoPage As Visio.Page
    Dim exportPath As String
    Dim resolution As Double
  

    exportPath = "C:\Users\USERNAME\Desktop\11.bmp"
    resolution = 140
    
    Application.Settings.SetRasterExportResolution visRasterUseCustomResolution, resolution, resolution, visRasterPixelsPerInch
    
    
    
    Set vsoWindow = ActiveWindow
    Set vsoSelection = ActiveWindow.Selection
    

    If Not vsoSelection Is Nothing Then
        vsoSelection.Export (exportPath)
        MsgBox "Done.", vbInformation
          Else
        MsgBox "No selection", vbExclamation
    End If
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.